gumyr / cq_warehouse

A cadquery parametric part collection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to run unit tests due to missing "BaseTest"

alikureishy opened this issue · comments

I'm trying to run the unit tests with:

python -m unittest -v tests.fastener_tests

but hit an error:

E
======================================================================
ERROR: fastener_tests (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: fastener_tests
Traceback (most recent call last):
  File "/home/safdar/anaconda3/envs/ros1/lib/python3.8/unittest/loader.py", line 154, in loadTestsFromName
    module = __import__(module_name)
  File "/home/safdar/code/repositories/cq_warehouse/tests/fastener_tests.py", line 32, in <module>
    from tests import BaseTest
ImportError: cannot import name 'BaseTest' from 'tests' (unknown location)
----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)

I don't see a 'BaseTest' class defined anywhere in the tests folder. Am I missing something?

There's no __init__.py in the tests folder at the moment. Was that a missed check-in?

cq_warehouse is using the same test setup as cadquery where BaseTest is imported as:
from tests import BaseTest
and in cadquery/tests there is an __init__.py file with:

import unittest
...
class BaseTest(unittest.TestCase):
    def assertTupleAlmostEquals(self, expected, actual, places, msg=None):
        for i, j in zip(actual, expected):
            self.assertAlmostEqual(i, j, places, msg=msg)
...

The existing unit tests do use assertTupleAlmostEquals() but now that I see the direct coupling between the projects I'm not sure that is a good thing.

As of release 0.4.0, all tests are now independent of BaseTest.