StephanosHadjimylos
StephanosHadjimylos

Reputation: 11

Pytest: KeyError: WindowsPath('D:/Local_Project_Directory/Lib/site-packages/matplotlib/testing/conftest.py')

I'm new to Pytest and developing in general.. I am trying to run a simple pytest assertion, however am getting the error:

KeyError: WindowsPath('D:/ireact-tester-if/Lib/site-packages/matplotlib/testing/conftest.py')

During handling of the above exception, another exception occurred:
lib\site-packages\py\_path\common.py:383: in visit
    for x in Visitor(fil, rec, ignore, bf, sort).gen(self):
lib\site-packages\py\_path\common.py:435: in gen
    for p in self.gen(subdir):
lib\site-packages\py\_path\common.py:435: in gen
    for p in self.gen(subdir):
lib\site-packages\py\_path\common.py:435: in gen
    for p in self.gen(subdir):
lib\site-packages\py\_path\common.py:424: in gen
    dirs = self.optsort([p for p in entries
lib\site-packages\py\_path\common.py:425: in <listcomp>
    if p.check(dir=1) and (rec is None or rec(p))])
lib\site-packages\_pytest\main.py:626: in _recurse
    ihook = self.gethookproxy(dirpath)
lib\site-packages\_pytest\main.py:445: in gethookproxy
    my_conftestmodules = pm._getconftestmodules(fspath)
lib\site-packages\_pytest\config\__init__.py:437: in _getconftestmodules
    mod = self._importconftest(conftestpath)
lib\site-packages\_pytest\config\__init__.py:484: in _importconftest
    self.consider_conftest(mod)
lib\site-packages\_pytest\config\__init__.py:537: in consider_conftest
    self.register(conftestmodule, name=conftestmodule.__file__)
lib\site-packages\_pytest\config\__init__.py:343: in register
    ret = super().register(plugin, name)
lib\site-packages\pluggy\manager.py:127: in register
    hook._maybe_apply_history(hookimpl)
lib\site-packages\pluggy\hooks.py:333: in _maybe_apply_history
    res = self._hookexec(self, [method], kwargs)
lib\site-packages\pluggy\manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
lib\site-packages\pluggy\manager.py:87: in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
Lib\site-packages\matplotlib\testing\conftest.py:10: in pytest_configure
    matplotlib._init_tests()
Lib\site-packages\matplotlib\__init__.py:1361: in _init_tests
    faulthandler.enable()
E   AttributeError: 'LogFile' object has no attribute 'fileno'

The pytest script I am trying to run is simply:

import pytest

@pytest.fixture(scope='module')
def nominal():
    x=1
    y=2
    yield x, y

def test_one(nominal):
    assert nominal[1] > nominal[0]

I am using pyenv with python 3.6.8, I have pytest and all its associated libraries installed. I have no idea why this is happening. Does anyone have any clues on how to solve this?

Upvotes: 1

Views: 739

Answers (1)

Mike M&#252;ller
Mike M&#252;ller

Reputation: 85512

You can specify multiple test directories pytest will use:

pytest <my_test_directory1> <my_test_directory2> <my_test_directory3>

Replace <my_test_directory1> with the first directory and <my_test_directory2> with the second directory that contain your tests.

Upvotes: 1

Related Questions