epogrebnyak / data-rosstat-kep

Time series dataset of Rosstat Short-term Economic Indicators ("KEP") publication
http://www.gks.ru/wps/wcm/connect/rosstat_main/rosstat/ru/statistics/publications/catalog/doc_1140080765391
6 stars 6 forks source link

Import problems fixed + test #63

Closed alexanderlukanin13 closed 8 years ago

alexanderlukanin13 commented 8 years ago

Sphinx requires all your modules to be importable without major side-effects (that is, no executable code at global level). There were two nasty problems preventing Sphinx from working properly.

  1. In var_names.py, default dict was initialized at import time. I changed that to lazy initialization on first use. Still not very portable (it uses relative path), but at least it doesn't fail on import.
  2. In test_label_csv.py, some test data was initialized on global level (again, using relative import described above). For now, I simply copypasted necessary calls into individual tests. We can later refactor it to use a common test class or something.

Also, I added test_import.py to make sure this problem won't happen again.

alexanderlukanin13 commented 8 years ago

I'll rather refactor the tests themselves, it's just as fast. Since py.test is our primary test tool, I'm going to use fixtures.

By the way, you can leave pull request open if it's not good enough - just leave a comment and I'll add appropriate changes.