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

Attribute error in Django 2.0 #177

Closed
dizballanze opened this issue Jan 17, 2018 · 12 comments
Closed

Attribute error in Django 2.0 #177

dizballanze opened this issue Jan 17, 2018 · 12 comments
Labels

Comments

@dizballanze
Copy link
Contributor

dizballanze commented Jan 17, 2018

Hi, seems that green doesn't work with Django 2.0.

# python manage.py test

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/home/vagrant/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/home/vagrant/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/vagrant/venv/lib/python3.6/site-packages/django/core/management/commands/test.py", line 26, in run_from_argv
    super().run_from_argv(argv)
  File "/home/vagrant/venv/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/vagrant/venv/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
    output = self.handle(*args, **options)
  File "/home/vagrant/venv/lib/python3.6/site-packages/django/core/management/commands/test.py", line 59, in handle
    failures = test_runner.run_tests(test_labels)
  File "/home/vagrant/venv/lib/python3.6/site-packages/green/djangorunner.py", line 124, in run_tests
    result = run(suite, stream, args)
  File "/home/vagrant/venv/lib/python3.6/site-packages/green/runner.py", line 115, in run
    result.addProtoTestResult(proto_test_result)
  File "/home/vagrant/venv/lib/python3.6/site-packages/green/result.py", line 346, in addProtoTestResult
    for test, err in proto_test_result.errors:
AttributeError: 'NoneType' object has no attribute 'errors'
@CleanCut
Copy link
Owner

@dizballanze I have not been able to reproduce this error. I have been experimenting with:

  • django 2.0.1
  • green 2.12.0
  • coverage 4.4.2
  • python 3.6.4
  • on macOS 10.13.2

Can you provide some way to reproduce the error? If you are working on an open source project, I could try that directly. If not, it would be great if you could produce a small django project which simply reproduces the error.

If you could also provide me with your OS and component versions, that may help.

@CleanCut CleanCut added the bug label Jan 19, 2018
@CleanCut
Copy link
Owner

Also, what does your config file look like, and where is it located relative to your project?

@dizballanze
Copy link
Contributor Author

dizballanze commented Jan 20, 2018

I use packages and Python version as you described above.

Sometimes it raises described above error. In other tries, it raises a bunch of database errors for some of the tests while other tests pass. Some of the errors it raises:

  File "/home/vagrant/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 83, in _execute
    return self.cursor.execute(sql)
psycopg2.DatabaseError: SSL error: decryption failed or bad record mac

I managed to fix this by setting ssl = false in postgresql.conf. But why this works with default test runner?

django.db.transaction.TransactionManagementError: An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block.

Many of psycopg2.IntegrityError

@Ogaday
Copy link
Contributor

Ogaday commented Jan 22, 2018

Just a hunch, as I don't know anything about Django, but this has the hallmarks of concurrency errors.

I had similar issues in another project, wherein green would through different errors on different runs, and using python -m unittest instead didn't raise any errors at all. I figured out that it was because I hadn't considered the fact that green uses multiprocessing, and I was accessing the same the resources in different test modules. Could it be the same situation here?

@CleanCut
Copy link
Owner

It could be the same situation. For systems not designed for concurrent testing (django), I recommend specifying in your green configuration file to use only one process.

processes = 1

Please let me know if that helps. If it does, then I will add that advice to the Django section of the readme.

@CleanCut
Copy link
Owner

Hmm...if the multiprocessing ended up being the problem, it may be worth adding a feature to Green to auto-detect when it is running under Django and defaulting to 1 process in that case.

@dizballanze
Copy link
Contributor Author

It works with processes = 1.
But it's possible to run tests in parallel since version 1.9 with default Django test runner.

@CleanCut
Copy link
Owner

Okay, I'll go ahead and close this, then.

@dizballanze
Copy link
Contributor Author

Maybe green can support parallel tests in new versions of Django? I've tried to set --parallel option of the Django test runner equal to processes from green. It works but some tests still failing with database errors.

@CleanCut
Copy link
Owner

That would be cool. Does Django have any documentation about how a test runner can interact with Django to support parallel tests?

@charlsagente
Copy link

@CleanCut It is possible in the django documentation. https://docs.djangoproject.com/en/2.0/topics/testing/overview/ with the --parallel flag. BTW Thanks I had the same issue and processes=1 solved the issue.

@CleanCut
Copy link
Owner

@charlsagente Awesome, I'm so glad it solved the problem for you!

Also, thank you for the pointer to the --parallel flag. I created #190 to track making Django integration more pleasant.

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

No branches or pull requests

4 participants