parameterized icon indicating copy to clipboard operation
parameterized copied to clipboard

"TypeError: don't know how to make test from: None" when executing just the test method.

Open luanfonceca opened this issue 3 years ago • 4 comments

It does look that this is the same issue as: #37

I just faced that very same issue: TypeError: don't know how to make test from: None using Django==3.2.14, Python=3.9.5, and parametrized==0.8.1, note that I'm using the plain unittest with no other libraries like Nosetests, Pytests etc. It's just the regular Django' unittest suite.

$ python manage.py test appname.tests.test_file.TestClass.test_method
...
TypeError: don't know how to make test from: None

All the other alternatives to run tests, like the whole test suite, executing just an app, files or even just the Test Class, it works with no issues. Is there any workaround to it? I ask that because this is kind of a blocker for us, thinking on an developer experience POV.

Thanks in advance.

luanfonceca avatar Sep 05 '22 13:09 luanfonceca

Bumping this!

hCraker avatar Dec 19 '22 23:12 hCraker

Hey! Would you be able to provide an example of the test case which is causing this failure?

wolever avatar Mar 27 '23 01:03 wolever

This happens with all tests decorated with parameterized.expand() because the original method (TestClass.test_method in this example) is removed and new ones created test_method_0, test_method_1.

It was already discussed in https://github.com/wolever/parameterized/issues/37

washeck avatar Sep 18 '23 12:09 washeck

@wolever As mentioned previously, it's the same issue as #37.

Full example, using unittest (python v. 3.10) and parameterized version 0.9.0.


import unittest
from parameterized import parameterized


def add_one(num: int) -> int:
	return num + 1


class TestAddOne(unittest.TestCase):

	@parameterized.expand([
		(8, 9),
		(0, 1),
		(254, 255)
	])
	def test_add_one(self, num, expected):
		self.assertEqual(expected, add_one(num))

When running the whole test suite, the run passes as expected:

Launching unittests with arguments python -m unittest test_example.TestAddOne
Ran 3 tests in 0.001s
OK

As mentioned, the individual test methods are created (Pycharm): image

However when executing the singular test method, the run will fail:

Launching unittests with arguments python -m unittest test_example.TestAddOne.test_add_one

 File ".../lib/python3.10/unittest/loader.py", line 214, in loadTestsFromName
    raise TypeError("don't know how to make test from: %s" % obj)
TypeError: don't know how to make test from: None

Will this be enough as an example? Thanks for having a look.

mcvincekova avatar Jan 19 '24 11:01 mcvincekova