Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
luanfonceca opened this issue Sep 5, 2022 · 4 comments

Comments

@luanfonceca
Copy link

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.

@hCraker
Copy link

hCraker commented Dec 19, 2022

Bumping this!

@wolever
Copy link
Owner

wolever commented Mar 27, 2023

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

@washeck
Copy link

washeck commented Sep 18, 2023

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 #37

@mcvincekova
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants