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

Unit tests against unknown/missing test fail with unrelated error #3534

Closed
PavelSafronov opened this issue Apr 3, 2023 · 0 comments · Fixed by #3959
Closed

Unit tests against unknown/missing test fail with unrelated error #3534

PavelSafronov opened this issue Apr 3, 2023 · 0 comments · Fixed by #3959
Assignees
Labels
type: housekeeping Changes to the application which do not directly impact the end user

Comments

@PavelSafronov
Copy link
Contributor

Environment

  • Nautobot version: tip of develop, tested with commit 4b04a36
  • Python version: 3.7
  • Database platform, version: unsure
  • Middleware(s): unsure

Steps to Reproduce

  1. run unit test that does not exist, for example inv unittest -l super_duper_fake_test

Expected Behavior

An error that says something like "test super_duper_fake_test" not found.

Observed Behavior

...
Seeding the pseudo-random number generator with seed "Nautobot"...
Creating Statuses...

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.7/site-packages/django_prometheus/db/common.py", line 71, in execute
    return super().execute(*args, **kwargs)
psycopg2.errors.UndefinedTable: relation "django_content_type" does not exist
LINE 1: ..."."app_label", "django_content_type"."model" FROM "django_co...
                                                             ^


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/source/nautobot/core/cli.py", line 180, in <module>
    main()
  File "/source/nautobot/core/cli.py", line 61, in main
    initializer=_configure_settings,  # Called after defaults
  File "/source/nautobot/core/runner/runner.py", line 263, in run_app
    management.execute_from_command_line([runner_name, command] + command_args)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/test.py", line 23, in run_from_argv
    super().run_from_argv(argv)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/test.py", line 55, in handle
    failures = test_runner.run_tests(test_labels)
  File "/usr/local/lib/python3.7/site-packages/django/test/runner.py", line 725, in run_tests
    old_config = self.setup_databases(aliases=databases)
  File "/source/nautobot/core/tests/runner.py", line 64, in setup_databases
    call_command(*command)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 181, in call_command
    return command.execute(*args, **defaults)
  File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/source/nautobot/core/management/commands/generate_test_data.py", line 152, in handle
    self._generate_factory_data(options["seed"])
  File "/source/nautobot/core/management/commands/generate_test_data.py", line 79, in _generate_factory_data
    populate_status_choices(verbosity=0)
  File "/source/nautobot/extras/management/__init__.py", line 99, in populate_status_choices
    create_custom_statuses(app_config, **kwargs)
  File "/source/nautobot/extras/management/__init__.py", line 167, in create_custom_statuses
    content_type = ContentType.objects.get_for_model(apps.get_model(model_path))
  File "/usr/local/lib/python3.7/site-packages/django/contrib/contenttypes/models.py", line 51, in get_for_model
    ct = self.get(app_label=opts.app_label, model=opts.model_name)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/cacheops/query.py", line 351, in get
    return qs._no_monkey.get(qs, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 431, in get
    num = len(clone)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 262, in __len__
    self._fetch_all()
  File "/usr/local/lib/python3.7/site-packages/cacheops/query.py", line 271, in _fetch_all
    return self._no_monkey._fetch_all(self)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 1324, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 51, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1175, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.7/site-packages/cacheops/transaction.py", line 97, in execute
    result = self._no_monkey.execute(self, sql, params)
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.7/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.7/site-packages/django_prometheus/db/common.py", line 71, in execute
    return super().execute(*args, **kwargs)
django.db.utils.ProgrammingError: relation "django_content_type" does not exist
LINE 1: ..."."app_label", "django_content_type"."model" FROM "django_co...
                                                             ^

Notes

I found this error when there was a typo in the test name: nautobot.utilities.tests.test_filters.NaturalKeyOrPKMultipleChoiceFilterTest.test_filter_multiple_name_excludetes.
The correct test is test_filter_multiple_name_excludetes. The tes on the end caused this entirely unrelated error and I ended up spending close to an hour debugging Docker, back-tracking through my commits, setting up a new clean repo, etc. before noticing the typo in the test name. :(

@bryanculver bryanculver added the type: housekeeping Changes to the application which do not directly impact the end user label Apr 4, 2023
@gsnider2195 gsnider2195 self-assigned this Jun 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: housekeeping Changes to the application which do not directly impact the end user
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants