TypeError: make() takes exactly 1 argument

Asked by Max Magee on 2011-04-15

I'm working on an implementation of testresources for unit testing. We have a Selenium process that we'd like to share among the test cases as it is extremely expensive to set up and tear down for each case, and testresources seems to be the way to go. I've followed the example here (http://code.mumak.net/2008/10/testresources-some-examples.html, specifically the complex-example-3.py file) and when my simple (simple so as to test the function before we shove the whole suite in) test cases were run via the unittest.TextTestRunner call, I receive an error from setUp:

setUp() takes exactly 2 arguments (1 given)
  File "C:\Python26\lib\unittest.py", line 270, in run

Decomposing the code a little bit further, I get a deeper stack trace that tells me that it's testresources that isn't happy:

Traceback (most recent call last):
  File "C:\Users\max.magee\...\lib\testresources-0.2.4-py2.7.egg\testresources\__init__.py", line 638, in setUp
  File "C:\Users\max.magee\...\lib\testresources-0.2.4-py2.7.egg\testresources\__init__.py", line 641, in setUpResources
     setUpResources(self, self.resources, _get_result())
  File "C:\Users\max.magee\...\lib\testresources-0.2.4-py2.7.egg\testresources\__init__.py", line 659, in setUpResources
     setattr(test, resource[0], resource[1].getResource(result))
  File "C:\Users\max.magee\...\lib\testresources-0.2.4-py2.7.egg\testresources\__init__.py", line 490, in getResource
  File "C:\Users\max.magee\...\lib\testresources-0.2.4-py2.7.egg\testresources\__init__.py", line 520, in _make_all
     resource = self.make(dependency_resources)
TypeError: make() takes exactly 1 argument (2 given)

I reconstructed the example from Mere Code out of exasperation (couldn't figure out why mine didn't work when it should have been exactly consistent with the setup of the author's complex-example-3.py), and I found that the example code had the same error. Yuck. I contacted the author and he directed me here, saying maybe something had changed in the intervening 4 years since he had used it.

Anyhow, I can post my code if that would help, especially if this isn't a known issue that has a fun and exciting fix.

Question information

English Edit question
testresources Edit question
No assignee Edit question
Solved by:
Max Magee
Last query:
Last reply:
Max Magee (max-magee) said : #1

It was probably a result in a change in the testresources API, but the example overrides the make instance of testResourceManager (as is required by the package). Unfortunately, make(self) is inconsistent with the make(self, dependencyresource) implementation in the package.

To correct the example, substitute <def make(self, dependencyresource):> for the original declaration and it then works. After troubleshooting my own code that used the example, I found that error- wanted to answer my original query for future reference.