Organization of Python tests


#1

I’m not completely happy with the organization of the Python tests. test_api.py is to big, the flat structure of the tests doesn’t mirror the rest of the code which makes it harder to navigate, and it seems wrong for the tests to be in the main code directory. I suggest the following new organization:

hail/python/
  hail/ - the main Python source
  test/
    test_hail.py - test file for hail module, or
    test_hail/
      test_table.py
      test_matrixtable.py
      test_stats.py - test file for hail.stats module
      ...

The tests for module a.b.c will be in test/test_a/test_b/test_c.py. You can have test_hail.py and a test_hail directory if you need to test hail submodules. I’m also open to having it be in test/a/b/test_c.py.

Each test_....py file should have a single class Test(unittest.TestCase) .


#2

Is there a technical reason why we have to prefix the files in test with test_?


#3

pytest won’t run it otherwise, I think :confused:


#4

unless we decorate them instead, or something


#5

ah, the files. I think by convention.


#6

I’ll take a stab at this.


#7

I’d guess there are some potential annoyances in having files with the same name, only disambiguated by path.


#8

doing this is pretty horrible. I think I’m halfway done though.