Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings conflicts with py.test #139

Closed
tony opened this issue Oct 15, 2022 · 2 comments
Closed

Settings conflicts with py.test #139

tony opened this issue Oct 15, 2022 · 2 comments

Comments

@tony
Copy link
Member

tony commented Oct 15, 2022

It may be easier to have an app settings structure like this to avoid modifying sys.modules[__name__] = Settings() (see 5.0's settings) as this adds complexity to imports, preventing simplification of maintenance / testing / etc #136

poetry run py.test                                                                                                                                                                                                                           ============================ test session starts =============================                                                                                                                                                               collected 0 items / 1 error                                                                                                                                                                                                                                                                                                                                                                                                                                                               =================================== ERRORS ===================================                                                                                                                                                               __________________ ERROR collecting src/robots/settings.py ___________________                                                                                                                                                               .venv/lib/python3.10/site-packages/_pytest/runner.py:338: in from_call                                                                                                                                                                           result: Optional[TResult] = func()                                                                                                                                                                                                               cls        = <class '_pytest.runner.CallInfo'>                                                                                                                                                                                               duration   = 0.0004884000009042211                                                                                                                                                                                                           excinfo    = <ExceptionInfo ImportPathMismatchError('robots.settings', None, PosixPath('~/work/python/django-robots/src/robots/settings.py')) tblen=4>                                                                                 func       = <function pytest_make_collect_report.<locals>.<lambda> at 0x7f95b64d1480>                                                                                                                                                       precise_start = 43076.9144613                                                                                                                                                                                                                precise_stop = 43076.9149497                                                                                                                                                                                                                 reraise    = None                                                                                                                                                                                                                            result     = None                                                                                                                                                                                                                            start      = 1665841416.0452023                                                                                                                                                                                                              stop       = 1665841416.045692                                                                                                                                                                                                               when       = 'collect'                                                                                                                                                                                                               .venv/lib/python3.10/site-packages/_pytest/runner.py:369: in <lambda>                                                                                                                                                                            call = CallInfo.from_call(lambda: list(collector.collect()), "collect")                                                                                                                                                                          collector  = <DoctestModule settings.py>                                                                                                                                                                                             .venv/lib/python3.10/site-packages/_pytest/doctest.py:545: in collect                                                                                                                                                                            module = import_path(                                                                                                                                                                                                                            MockAwareDocTestFinder = <class '_pytest.doctest.DoctestModule.collect.<locals>.MockAwareDocTestFinder'>                                                                                                                                     doctest    = <module 'doctest' from '~/.python/installs/python/3.10.7/lib/python3.10/doctest.py'>                                                                                                                                self       = <DoctestModule settings.py>                                                                                                                                                                                             .venv/lib/python3.10/site-packages/_pytest/pathlib.py:543: in import_path
    raise ImportPathMismatchError(module_name, module_file, path)
E   _pytest.pathlib.ImportPathMismatchError: ('robots.settings', None, PosixPath('~/work/python/django-robots/src/robots/settings.py'))                                                                                                        ignore     = ''
        mod        = <robots.settings.Settings object at 0x7f95b6133f10>
        mode       = <ImportMode.prepend: 'prepend'>
        module_file = None
        module_name = 'robots.settings'
        names      = ['robots', 'settings']
        p          = PosixPath('~/work/python/django-robots/src/robots/settings.py')
        path       = PosixPath('~/work/python/django-robots/src/robots/settings.py')
        pkg_path   = PosixPath('~/work/python/django-robots/src/robots')
        pkg_root   = PosixPath('~/work/python/django-robots/src')
        root       = PosixPath('~/work/python/django-robots')
========================== short test summary info ===========================                                                                                                                                                               ERROR src/robots/settings.py - _pytest.pathlib.ImportPathMismatchError: ('r...
!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!
============================== 1 error in 0.20s ==============================
make[1]: *** [Makefile:24: test] Error 2
make[1]: Leaving directory '~/work/python/django-robots'
make[1]: Entering directory '~/work/python/django-robots'
poetry run py.test
============================ test session starts =============================
collected 0 items / 4 errors
@tony
Copy link
Member Author

tony commented Oct 15, 2022

Ultimately, it didn't overall simplify much - since settings_changed is needing in the TestCases

@tony
Copy link
Member Author

tony commented Oct 16, 2022

It may be worth seeing if there's a standard / best practice jazzband would like to establish for django testing (just use unittest with django.test? or pytest w/ pytest-django?)

At this time I don't have the ability to maintain / deliberate the change - so to avoid the impression of being able to commit the time I will close for now

Anyone is welcome to reference / bring this up later.

@tony tony closed this as completed Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant