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

TESTED_VERSIONS is ignored in tox? #15

Open
pllim opened this issue Dec 31, 2019 · 12 comments
Open

TESTED_VERSIONS is ignored in tox? #15

pllim opened this issue Dec 31, 2019 · 12 comments
Labels
bug Something isn't working

Comments

@pllim
Copy link
Member

pllim commented Dec 31, 2019

I set custom TESTED_VERSIONS in astropy/astrowidgets#103 but it does not seem to work, as the test log still shows:

Running tests with Astropy version 4.0.
Running tests in astrowidgets docs.

It works in my other projects. The only difference I can think of is that astrowidgets is using tox, unlike the others that I am using for comparison.

@weaverba137
Copy link
Member

I am seeing similar behaviour in a variety of testing scenarios, all involving tox.

@pllim
Copy link
Member Author

pllim commented Nov 12, 2020

I think this is the issue that @bsipocz and @larrybradley also ran into.

@pllim pllim added the bug Something isn't working label Nov 16, 2020
@pllim
Copy link
Member Author

pllim commented Nov 18, 2020

Maybe this is not robust enough:

# TESTED_VERSIONS can contain the affiliated package version, too
if len(TESTED_VERSIONS) > 1:
for pkg, version in TESTED_VERSIONS.items():
if pkg not in ['Astropy', 'astropy_helpers']:
s = "\nRunning tests with {} version {}.\n".format(
pkg, version)
else:
s = "\nRunning tests with Astropy version {}.\n".format(
TESTED_VERSIONS['Astropy'])

And perhaps if we remove the old checks in #32 , things will be easier to debug. 🤞

@pllim
Copy link
Member Author

pllim commented Nov 19, 2020

Hmm... Using this plugin and tox in stsci-package-template does not show this problem. I am not sure why!

============================= test session starts ==============================
platform linux -- Python 3.7.9, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
cachedir: .tox/py37-test-oldestdeps/.pytest_cache

Running tests with packagename version 0.1.dev2+g7bfb23d.
Running tests in packagename docs.

xref spacetelescope/stsci-package-template#25

@saimn
Copy link
Contributor

saimn commented Jan 20, 2021

So after some investigation, the conftest.py is not always loaded if it is located in packagename/. It is loaded only if running pytest with some path argument. So the solution is to put conftest.py in the root directory (which is what is done for stsci-package-template but not for the other examples mentioned here).

@weaverba137
Copy link
Member

Thanx, I'll give that a test.

@pllim
Copy link
Member Author

pllim commented Jan 21, 2021

I think the reason we used to have packagename/conftest.py layout was for that test runner (i.e., python -c "import packagename; packagename.test()"), or so I thought @astrofrog said once.

@saimn
Copy link
Contributor

saimn commented Jan 21, 2021

Yes, I think you're right. So maybe an option is to duplicate the files...

@pllim
Copy link
Member Author

pllim commented Jan 21, 2021

duplicate the files

Not as clean but if it works, we could recommend it.

@astrofrog
Copy link
Member

I wonder if we could somehow have the main version be in the root directory and then copy it into the installation path when installing, to not actually have to duplicate it manually?

@pllim
Copy link
Member Author

pllim commented Jan 25, 2021

👎 to auto copying, as it really only affects the astropy test runner and pytest-astropy-header technically no longer depends on astropy (despite the name).

@pllim
Copy link
Member Author

pllim commented May 6, 2021

So, I just created a root level conftest.py to get around this problem. But for whatever reason, just having even an empty conftest.py in the root dir caused the path reported by tox run to change from:

..\..\.tox\py38-test\lib\site-packages\jdaviz\configs\...

to

..\..\jdaviz\configs\...

❗ ❗ ❗

What I am doing wrong? 🤯

xref spacetelescope/jdaviz#583

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants