pythonpython-3.xnose

How to use Nose tests to test an individual method on a Mac?


I'm using Nose tests to test a particular function. After entering the correct file directory, I run the following command in the Mac terminal: nosetests test_hardening.py: TestVoceIsotropicThetaHardening.test_dhistory.

test_hardening.py is a python file, TestVoceIsotropicThetaHardening is a python class, and test_dhistory is the particular method I am running tests on.

I am consistently getting the following error: ModuleNotFoundError: No module named 'TestVoceIsotropicThetaHardening'.

For your reference, here is a snippet of my code:

class HardeningBase:
  def test_dhistory(self):
    ... # some code to calculate rv1, rv2, rv3, exact, and number
    print(rv1)
    print(rv2)
    print(rv3)
    self.assertTrue(np.allclose(exact, numer, rtol=1.0e-3))

class TestVoceIsotropicThetaHardening(unittest.TestCase, HardeningBase):
  def setUp(self):
    self.a = 1
    self.b = 2
    self.c = 3

Is there a particular way for me to test test_dhistory of the child class TestVoceIsotropicThetaHardening using Nose on a Mac terminal?


Solution

  • Resolved the problem:

    nosetests test_hardening.py:TestVoceIsotropicThetaHardening.test_dhistory

    instead of

    nosetests test_hardening.py: TestVoceIsotropicThetaHardening.test_dhistory - you can't leave a space in-between the colon and the class name.