rlgomes/pocha

Cant run pocha on relative path starting with `test`

matutter opened this issue · 3 comments

Pocha fails to import and run tests from a directory root of "test"

# Fails, no module named test
pocha test/test.py

Possible work around in discovery.py:search

for module in modules:
  module_path = os.path.dirname(module)
  sys_path = sys.path
  sys.path = ['.', module_path]
  try:
    ...
  finally:
    sys.path = sys_path

@matutter Are you trying to run from a test directory that doesn't have a init.py file in it ? ie its not a valid python module.

My bad, having any python file in the directory with the same name as the .py causes import errors. ie, test/test.py cannot be imported, even with an __init__.py.

@matutter I'll have a look this weekend and probably just use your suggestion, thanks!