0

python3 manage.py test apps.favorites

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/dmitry/.pyenv/versions/p/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_e
    utility.execute()
  File "/home/dmitry/.pyenv/versions/p/lib/python3.5/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/dmitry/.pyenv/versions/p/lib/python3.5/site-packages/django/core/management/commands/test.py", line 29, in run_v
    super(Command, self).run_from_argv(argv)
  File "/home/dmitry/.pyenv/versions/p/lib/python3.5/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/dmitry/.pyenv/versions/p/lib/python3.5/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/home/dmitry/.pyenv/versions/p/lib/python3.5/site-packages/django/core/management/commands/test.py", line 72, in hande
    failures = test_runner.run_tests(test_labels)
  File "/home/dmitry/.pyenv/versions/p/lib/python3.5/site-packages/django/test/runner.py", line 548, in run_tests
    suite = self.build_suite(test_labels, extra_tests)
  File "/home/dmitry/.pyenv/versions/p/lib/python3.5/site-packages/django/test/runner.py", line 466, in build_suite
    tests = self.test_loader.discover(start_dir=label, **kwargs)
  File "/home/dmitry/.pyenv/versions/3.5.1/lib/python3.5/unittest/loader.py", line 341, in discover
    tests = list(self._find_tests(start_dir, pattern))
  File "/home/dmitry/.pyenv/versions/3.5.1/lib/python3.5/unittest/loader.py", line 406, in _find_tests
    yield from self._find_tests(full_path, pattern, namespace)
  File "/home/dmitry/.pyenv/versions/3.5.1/lib/python3.5/unittest/loader.py", line 398, in _find_tests
    full_path, pattern, namespace)
TypeError: 'NoneType' object is not iterable
Very cryptic message with no details. Everything was working last night.
apps/favorites
├── admin.py
├── api
│   ├── __init__.py
│   ├── mixins.py
│   ├── permissions.py
│   └── __pycache__
│       ├── __init__.cpython-35.pyc
│       ├── mixins.cpython-35.pyc
│       └── permissions.cpython-35.pyc
├── apps.py
├── __init__.py
├── managers.py
├── migrations
│   ├── 0001_initial.py
│   ├── __init__.py
│   └── __pycache__
│       ├── 0001_initial.cpython-35.pyc
│       └── __init__.cpython-35.pyc
├── models.py
├── __pycache__
│   ├── admin.cpython-35.pyc
│   ├── apps.cpython-35.pyc
│   ├── __init__.cpython-35.pyc
│   ├── managers.cpython-35.pyc
│   └── models.cpython-35.pyc
└── tests
    ├── __init__.py
    ├── __pycache__
    │   ├── __init__.cpython-35.pyc
    │   └── test_models.cpython-35.pyc
    └── test_models.py

7 directories, 24 files
DmitrySemenov
  • 9,204
  • 15
  • 76
  • 121
  • Show us the `apps.favorites` module. – John Gordon May 25 '17 at 17:49
  • John, you mean a test_models.py or? – DmitrySemenov May 25 '17 at 17:56
  • Please read and follow the posting guidelines in the help documentation. [Minimal, complete, verifiable example](http://stackoverflow.com/help/mcve) applies here. We cannot effectively help you until you post your MCVE code and accurately describe the problem. We should be able to paste your posted code into a text file and reproduce the problem you described. – Prune May 25 '17 at 17:59
  • @DmitrySemenov According to the Django documentation, the command `python3 manage.py test apps.favorites` will discover and run all test cases in the `apps.favorites` module. So, we can't help you diagnose your issue without seeing that module. – John Gordon May 25 '17 at 18:13
  • so I removed the apps.favorites and then restored it from previous revisions. The tests are worked 100% but I then made a diff on dirs and it shows ZERO changes. Very **awkward!**, like I said it was working a day before and then stopped. – DmitrySemenov May 25 '17 at 18:31

1 Answers1

1

This usually happens when you expect a list (or other sequence) returned from a function, but get an empty result of None. If you then give this supposed list to something that requires iteration, such as a simple for loop, you get the error shown. For instance:

>>> oops = None
>>> for i in oops:
...     print i
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not iterable
Prune
  • 76,765
  • 14
  • 60
  • 81