Skip to content

Is there a way to run doctests? #131

@yarikoptic

Description

@yarikoptic

I wondered, since there are docstrings with code samples, and even the doc/fake__sounddevice.py may be you guys considered already (so I do not need to fight the windmill) to run the doctests? On my semi-blind attempt:

$> python -m nose --with-doctest sounddevice.py             
FFFFF
======================================================================
FAIL: Doctest: sounddevice.AsioSettings.__init__
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.6/doctest.py", line 2199, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for sounddevice.AsioSettings.__init__
  File "/home/yoh/deb/gits/python-sounddevice/sounddevice.py", line 2093, in __init__

----------------------------------------------------------------------
File "/home/yoh/deb/gits/python-sounddevice/sounddevice.py", line 2117, in sounddevice.AsioSettings.__init__
Failed example:
    sd.play(..., extra_settings=asio_out)
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python3.6/doctest.py", line 1330, in __run
        compileflags, 1), test.globs)
      File "<doctest sounddevice.AsioSettings.__init__[2]>", line 1, in <module>
        sd.play(..., extra_settings=asio_out)
      File "/home/yoh/deb/gits/python-sounddevice/sounddevice.py", line 135, in play
        ctx.frames = ctx.check_data(data, mapping, kwargs.get('device'))
      File "/home/yoh/deb/gits/python-sounddevice/sounddevice.py", line 2306, in check_data
        dtype = _check_dtype(data.dtype)
      File "/home/yoh/deb/gits/python-sounddevice/sounddevice.py", line 2459, in _check_dtype
        raise TypeError('Unsupported data type: ' + repr(dtype))
    TypeError: Unsupported data type: 'object'
----------------------------------------------------------------------
File "/home/yoh/deb/gits/python-sounddevice/sounddevice.py", line 2122, in sounddevice.AsioSettings.__init__
Failed example:
    sd.play(...)
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python3.6/doctest.py", line 1330, in __run
        compileflags, 1), test.globs)
      File "<doctest sounddevice.AsioSettings.__init__[4]>", line 1, in <module>
        sd.play(...)
      File "/home/yoh/deb/gits/python-sounddevice/sounddevice.py", line 135, in play
        ctx.frames = ctx.check_data(data, mapping, kwargs.get('device'))
      File "/home/yoh/deb/gits/python-sounddevice/sounddevice.py", line 2306, in check_data
        dtype = _check_dtype(data.dtype)
      File "/home/yoh/deb/gits/python-sounddevice/sounddevice.py", line 2459, in _check_dtype
        raise TypeError('Unsupported data type: ' + repr(dtype))
    TypeError: Unsupported data type: 'object'
----------------------------------------------------------------------
File "/home/yoh/deb/gits/python-sounddevice/sounddevice.py", line 2128, in sounddevice.AsioSettings.__init__
Failed example:
    sd.playrec(..., channels=1, ...)
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python3.6/doctest.py", line 1330, in __run
        compileflags, 1), test.globs)
      File "<doctest sounddevice.AsioSettings.__init__[7]>", line 1
    SyntaxError: positional argument follows keyword argument

...

so already not sure if that is something to investigate to see if could be made "proper".

P.S. but may be it is just me+Friday -- can't even build documentation :-(

$> which python                                
/home/yoh/deb/gits/python-sounddevice/venvs/dev3/bin/python
(dev3) 1 11269.....................................:Fri 06 Apr 2018 07:21:37 PM EDT:.
(git)hopa:~deb/python-sounddevice[master]git
$> python /usr/share/sphinx/scripts/python3/sphinx-build -P doc build/doc
Running Sphinx v1.6.7
Exception occurred while building, starting debugger:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/sphinx/cmdline.py", line 305, in main
    opts.warningiserror, opts.tags, opts.verbosity, opts.jobs)
  File "/usr/lib/python3/dist-packages/sphinx/application.py", line 192, in __init__
    self.setup_extension(extension)
  File "/usr/lib/python3/dist-packages/sphinx/application.py", line 456, in setup_extension
    self.registry.load_extension(self, extname)
  File "/usr/lib/python3/dist-packages/sphinx/registry.py", line 196, in load_extension
    mod = __import__(extname, None, None, ['setup'])
  File "/usr/lib/python3/dist-packages/sphinx/builders/linkcheck.py", line 18, in <module>
    from requests.exceptions import HTTPError
  File "/usr/lib/python3/dist-packages/requests/__init__.py", line 84, in <module>
    from urllib3.contrib import pyopenssl
  File "/usr/lib/python3/dist-packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 12, in <module>
    from cryptography import x509
  File "/usr/lib/python3/dist-packages/cryptography/x509/__init__.py", line 8, in <module>
    from cryptography.x509.base import (
  File "/usr/lib/python3/dist-packages/cryptography/x509/base.py", line 16, in <module>
    from cryptography.x509.extensions import Extension, ExtensionType
  File "/usr/lib/python3/dist-packages/cryptography/x509/extensions.py", line 13, in <module>
    from asn1crypto.keys import PublicKeyInfo
  File "/usr/lib/python3/dist-packages/asn1crypto/keys.py", line 22, in <module>
    from ._elliptic_curve import (
  File "/usr/lib/python3/dist-packages/asn1crypto/_elliptic_curve.py", line 51, in <module>
    from ._int import inverse_mod
  File "/usr/lib/python3/dist-packages/asn1crypto/_int.py", line 56, in <module>
    from ._perf._big_num_ctypes import libcrypto
  File "/usr/lib/python3/dist-packages/asn1crypto/_perf/_big_num_ctypes.py", line 39, in <module>
    libcrypto = CDLL(libcrypto_path)
  File "/usr/lib/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
TypeError: expected str, bytes or os.PathLike object, not NotImplementedType
> /usr/lib/python3.6/ctypes/__init__.py(348)__init__()
-> self._handle = _dlopen(self._name, mode)
(Pdb) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions