pytest-dev / apipkg

MIT License
55 stars 17 forks source link

1.5: pytest is failing #21

Closed kloczek closed 3 years ago

kloczek commented 3 years ago

I'm trying to package your module as an rpm package. So I'm using the typical build, install and test cycle used on building packages from non-root account.

May I ask for help because few units are failing:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-apipkg-1.5-15.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-apipkg-1.5-15.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
Using --randomly-seed=2863033127
apipkg full install version=1.5
rootdir: /home/tkloczko/rpmbuild/BUILD/apipkg-1.5
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, aspectlib-1.5.2, toolbox-0.5, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, flaky-3.7.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, xprocess-0.18.1, black-0.3.12, anyio-3.3.0, asyncio-0.15.1, subtests-0.5.0, isort-2.0.0, hypothesis-6.14.6, mock-3.6.1, profiling-1.7.0, randomly-3.8.0, Faker-8.12.1, nose2pytest-1.0.8, pyfakefs-4.5.1, tornado-0.8.1, twisted-1.13.3
collected 37 items

test_apipkg.py ....EEEEEEF..F............F..........                                                                                                                 [100%]

================================================================================== ERRORS ==================================================================================
_____________________________________________________________ ERROR at setup of TestRealModule.test_realmodule _____________________________________________________________

cls = <class 'test_apipkg.TestRealModule'>

    def setup_class(cls):
>       cls.tmpdir = py.test.ensuretemp('test_apipkg')

test_apipkg.py:16:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <AliasModule 'py.test' for 'pytest'>, name = 'ensuretemp'

    def __getattribute__(self, name):
        try:
>           return getattr(getmod(), name)
E           AttributeError: module 'pytest' has no attribute 'ensuretemp'

/usr/lib/python3.8/site-packages/py/_vendored_packages/apipkg/__init__.py:199: AttributeError
_______________________________________________________ ERROR at setup of TestRealModule.test_realmodule_dict_import _______________________________________________________

cls = <class 'test_apipkg.TestRealModule'>

    def setup_class(cls):
>       cls.tmpdir = py.test.ensuretemp('test_apipkg')

test_apipkg.py:16:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <AliasModule 'py.test' for 'pytest'>, name = 'ensuretemp'

    def __getattribute__(self, name):
        try:
>           return getattr(getmod(), name)
E           AttributeError: module 'pytest' has no attribute 'ensuretemp'

/usr/lib/python3.8/site-packages/py/_vendored_packages/apipkg/__init__.py:199: AttributeError
_________________________________________________________ ERROR at setup of TestRealModule.test_realmodule___doc__ _________________________________________________________

cls = <class 'test_apipkg.TestRealModule'>

    def setup_class(cls):
>       cls.tmpdir = py.test.ensuretemp('test_apipkg')

test_apipkg.py:16:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <AliasModule 'py.test' for 'pytest'>, name = 'ensuretemp'

    def __getattribute__(self, name):
        try:
>           return getattr(getmod(), name)
E           AttributeError: module 'pytest' has no attribute 'ensuretemp'

/usr/lib/python3.8/site-packages/py/_vendored_packages/apipkg/__init__.py:199: AttributeError
__________________________________________________________ ERROR at setup of TestRealModule.test_realmodule_repr ___________________________________________________________

cls = <class 'test_apipkg.TestRealModule'>

    def setup_class(cls):
>       cls.tmpdir = py.test.ensuretemp('test_apipkg')

test_apipkg.py:16:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <AliasModule 'py.test' for 'pytest'>, name = 'ensuretemp'

    def __getattribute__(self, name):
        try:
>           return getattr(getmod(), name)
E           AttributeError: module 'pytest' has no attribute 'ensuretemp'

/usr/lib/python3.8/site-packages/py/_vendored_packages/apipkg/__init__.py:199: AttributeError
_________________________________________________________ ERROR at setup of TestRealModule.test_realmodule__all__ __________________________________________________________

cls = <class 'test_apipkg.TestRealModule'>

    def setup_class(cls):
>       cls.tmpdir = py.test.ensuretemp('test_apipkg')

test_apipkg.py:16:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <AliasModule 'py.test' for 'pytest'>, name = 'ensuretemp'

    def __getattribute__(self, name):
        try:
>           return getattr(getmod(), name)
E           AttributeError: module 'pytest' has no attribute 'ensuretemp'

/usr/lib/python3.8/site-packages/py/_vendored_packages/apipkg/__init__.py:199: AttributeError
__________________________________________________________ ERROR at setup of TestRealModule.test_realmodule_from ___________________________________________________________

cls = <class 'test_apipkg.TestRealModule'>

    def setup_class(cls):
>       cls.tmpdir = py.test.ensuretemp('test_apipkg')

test_apipkg.py:16:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <AliasModule 'py.test' for 'pytest'>, name = 'ensuretemp'

    def __getattribute__(self, name):
        try:
>           return getattr(getmod(), name)
E           AttributeError: module 'pytest' has no attribute 'ensuretemp'

/usr/lib/python3.8/site-packages/py/_vendored_packages/apipkg/__init__.py:199: AttributeError
================================================================================= FAILURES =================================================================================
_________________________________________________________________________ test_eagerload_on_bython _________________________________________________________________________

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f693948f100>

    def test_eagerload_on_bython(monkeypatch):
        monkeypatch.delitem(sys.modules, 'bpython', raising=False)
        apipkg.initpkg(
            'apipkg.testmodule.example.lazy',
            {'test': 'apipkg.does_not_exist'})
        monkeypatch.setitem(sys.modules, 'bpython', True)
        with pytest.raises(ImportError):
>           apipkg.initpkg(
                'apipkg.testmodule.example.lazy',
                {'test': 'apipkg.does_not_exist'})
E           Failed: DID NOT RAISE <class 'ImportError'>

test_apipkg.py:548: Failed
______________________________________________________________________ test_error_loading_one_element ______________________________________________________________________

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f6939401490>, tmpdir = local('/tmp/pytest-of-tkloczko/pytest-85/test_error_loading_one_element0')

    def test_error_loading_one_element(monkeypatch, tmpdir):
        pkgdir = tmpdir.mkdir("errorloading1")
        pkgdir.join('__init__.py').write(py.code.Source("""
            import apipkg
            apipkg.initpkg(__name__, exportdefs={
                'x': '.notexists:x',
                'y': '.submod:y'
                },
            )
        """))
        pkgdir.join('submod.py').write("y=0")
        monkeypatch.syspath_prepend(tmpdir)
        import errorloading1
        assert isinstance(errorloading1, apipkg.ApiModule)
        assert errorloading1.y == 0
>       py.test.raises(ImportError, 'errorloading1.x')
E       TypeError: 'errorloading1.x' object (type: <class 'str'>) must be callable

test_apipkg.py:322: TypeError
______________________________________________________________________ test_aliasmodule_proxy_methods ______________________________________________________________________

tmpdir = local('/tmp/pytest-of-tkloczko/pytest-85/test_aliasmodule_proxy_methods0'), monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f69393e41c0>

    def test_aliasmodule_proxy_methods(tmpdir, monkeypatch):
        pkgdir = tmpdir
        pkgdir.join('aliasmodule_proxy.py').write(py.code.Source("""
            def doit():
                return 42
        """))

        pkgdir.join('my_aliasmodule_proxy.py').write(py.code.Source("""
            import apipkg
            apipkg.initpkg(__name__, dict(proxy='aliasmodule_proxy'))

            def doit():
                return 42
        """))

        monkeypatch.syspath_prepend(tmpdir)
        import aliasmodule_proxy as orig
        from my_aliasmodule_proxy import proxy

        doit = proxy.doit
        assert doit is orig.doit

        del proxy.doit
>       py.test.raises(AttributeError, "orig.doit")
E       TypeError: 'orig.doit' object (type: <class 'str'>) must be callable

test_apipkg.py:496: TypeError
========================================================================= short test summary info ==========================================================================
ERROR test_apipkg.py::TestRealModule::test_realmodule - AttributeError: module 'pytest' has no attribute 'ensuretemp'
ERROR test_apipkg.py::TestRealModule::test_realmodule_dict_import - AttributeError: module 'pytest' has no attribute 'ensuretemp'
ERROR test_apipkg.py::TestRealModule::test_realmodule___doc__ - AttributeError: module 'pytest' has no attribute 'ensuretemp'
ERROR test_apipkg.py::TestRealModule::test_realmodule_repr - AttributeError: module 'pytest' has no attribute 'ensuretemp'
ERROR test_apipkg.py::TestRealModule::test_realmodule__all__ - AttributeError: module 'pytest' has no attribute 'ensuretemp'
ERROR test_apipkg.py::TestRealModule::test_realmodule_from - AttributeError: module 'pytest' has no attribute 'ensuretemp'
FAILED test_apipkg.py::test_eagerload_on_bython - Failed: DID NOT RAISE <class 'ImportError'>
FAILED test_apipkg.py::test_error_loading_one_element - TypeError: 'errorloading1.x' object (type: <class 'str'>) must be callable
FAILED test_apipkg.py::test_aliasmodule_proxy_methods - TypeError: 'orig.doit' object (type: <class 'str'>) must be callable
================================================================== 3 failed, 28 passed, 6 errors in 1.30s ==================================================================
pytest-xprocess reminder::Be sure to terminate the started process by running 'pytest --xkill' if you have not explicitly done so in your fixture with 'xprocess.getinfo(<process_name>).terminate()'.
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:80: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-5909a714-aa1e-478a-8fa5-1449bc203d40/test_rmtree_errorhandler_reado0
<class 'OSError'>: [Errno 39] Directory not empty: 'test_rmtree_errorhandler_reado0'
  warnings.warn(
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:80: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-5909a714-aa1e-478a-8fa5-1449bc203d40/test_rmtree_errorhandler_rerai0
<class 'OSError'>: [Errno 39] Directory not empty: 'test_rmtree_errorhandler_rerai0'
  warnings.warn(
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:80: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-5909a714-aa1e-478a-8fa5-1449bc203d40/test_safe_set_no_perms0
<class 'OSError'>: [Errno 39] Directory not empty: 'test_safe_set_no_perms0'
  warnings.warn(
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:80: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-5909a714-aa1e-478a-8fa5-1449bc203d40/test_safe_delete_no_perms0
<class 'OSError'>: [Errno 39] Directory not empty: 'test_safe_delete_no_perms0'
  warnings.warn(
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:80: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-5909a714-aa1e-478a-8fa5-1449bc203d40/test_safe_get_no_perms0
<class 'OSError'>: [Errno 39] Directory not empty: 'test_safe_get_no_perms0'
  warnings.warn(
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:80: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-5909a714-aa1e-478a-8fa5-1449bc203d40
<class 'OSError'>: [Errno 39] Directory not empty: '/tmp/pytest-of-tkloczko/garbage-5909a714-aa1e-478a-8fa5-1449bc203d40'
  warnings.warn(
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:80: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-ea54b0a1-bfc0-4c2f-bf6c-c48de4de7a88/test_rmtree_errorhandler_reado0
<class 'OSError'>: [Errno 39] Directory not empty: 'test_rmtree_errorhandler_reado0'
  warnings.warn(
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:80: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-ea54b0a1-bfc0-4c2f-bf6c-c48de4de7a88/test_rmtree_errorhandler_rerai0
<class 'OSError'>: [Errno 39] Directory not empty: 'test_rmtree_errorhandler_rerai0'
  warnings.warn(
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:80: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-ea54b0a1-bfc0-4c2f-bf6c-c48de4de7a88/test_safe_get_no_perms0
<class 'OSError'>: [Errno 39] Directory not empty: 'test_safe_get_no_perms0'
  warnings.warn(
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:80: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-ea54b0a1-bfc0-4c2f-bf6c-c48de4de7a88/test_safe_set_no_perms0
<class 'OSError'>: [Errno 39] Directory not empty: 'test_safe_set_no_perms0'
  warnings.warn(
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:80: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-ea54b0a1-bfc0-4c2f-bf6c-c48de4de7a88/test_safe_delete_no_perms0
<class 'OSError'>: [Errno 39] Directory not empty: 'test_safe_delete_no_perms0'
  warnings.warn(
/usr/lib/python3.8/site-packages/_pytest/pathlib.py:80: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-ea54b0a1-bfc0-4c2f-bf6c-c48de4de7a88
<class 'OSError'>: [Errno 39] Directory not empty: '/tmp/pytest-of-tkloczko/garbage-ea54b0a1-bfc0-4c2f-bf6c-c48de4de7a88'
  warnings.warn(
RonnyPfannschmidt commented 3 years ago

this is fixed on master since a while, i just dont have the bandwidth for a release atm

kloczek commented 3 years ago

Have problems with locating exact commit. Is that issue in test suite or tested code? If it is first case feel free to close that ticked and I'll patiently wait until next release :)

RonnyPfannschmidt commented 3 years ago

its in the testsuite

closing as resolved but unreleased

kloczek commented 3 years ago

Thx :)

kloczek commented 3 years ago

Just tested 2.0.0. All looks good. One more time .. thank you :)

+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
Using --randomly-seed=1849500660
apipkg full install version=2.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/apipkg-2.0.0
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, aspectlib-1.5.2, toolbox-0.5, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, flaky-3.7.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, xprocess-0.18.1, black-0.3.12, asyncio-0.15.1, subtests-0.5.0, isort-2.0.0, hypothesis-6.14.6, mock-3.6.1, profiling-1.7.0, randomly-3.8.0, nose2pytest-1.0.8, pyfakefs-4.5.1, tornado-0.8.1, twisted-1.13.3, aiohttp-0.3.0, localserver-0.5.0, anyio-3.3.1, trio-0.7.0, Faker-8.12.2, cases-3.6.4, yagot-0.5.0
collected 41 items

test_apipkg.py .........................................                                                                                                             [100%]

============================================================================ 41 passed in 0.82s ============================================================================
pytest-xprocess reminder::Be sure to terminate the started process by running 'pytest --xkill' if you have not explicitly done so in your fixture with 'xprocess.getinfo(<process_name>).terminate()'.