> 
> Keep in mind that you need to tell tox to cd into tests/ before running 
> pytest, otherwise you’re testing the source directory instead of the 
> installed package.
> 
> https://tox.readthedocs.io/en/latest/config.html#confval-changedir=path 
> <https://tox.readthedocs.io/en/latest/config.html#confval-changedir=path>
> 
> I'm running the tests on the source directory using `python -m pytest' with 
> tox. Pytest collects all tests and runs it on the source, and all imports in 
> the test files are like 'from docwriter import ...' so I think this is the 
> right configuration. Am I missing something? 
> (https://travis-ci.com/nikramakrishnan/freetype-docwriter/jobs/136998196#L445 
> <https://travis-ci.com/nikramakrishnan/freetype-docwriter/jobs/136998196#L445>)
>  

This is a bit tricky in Python, see 
https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure 
<https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure>.

Basically, tox and therefore pytest is run from the project root directory, 
which happens to have the docwriter module-directory. Python by default has the 
current directory in the import path. pytest will collect the tests and run 
them — when they import docwriter, they will actually import the 
module-directory in the project root! You however want to test the package as 
installed by tox somewhere in .tox/…. Stepping out of the root directory, e.g. 
into the tests directory ensures this.
_______________________________________________
Freetype-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype-devel

Reply via email to