dusty-phillips / django-pytest Goto Github PK
View Code? Open in Web Editor NEWDjango testrunner for py.test with some helper funcargs
License: BSD 3-Clause "New" or "Revised" License
Django testrunner for py.test with some helper funcargs
License: BSD 3-Clause "New" or "Revised" License
The readme shows an example of a test written as a function. But will tests defined as methods of a django.test.TestCase
instance work as well? For those considering to migrate test suites this is an important question, and it should be included in the documentation.
I am using Django-Pytest and do not know if somehow you can set the Verbose parameter.
Thx.
I realise this is probably because pytest automatically generates these marks, and django-pytest uses them later, but it's quite...surprising to have your main database mutated by the tests :(
I have gotten around this by doing:
import django_pytest as _ # NOTE: Guarantees that pytest-django is installed.
Perhaps having an import alias in django_pytest might solve the problem? Something like:
from django_pytest import mark_django_db
Since version 2.0 pytest is its own package
http://pytest.org/changelog.html#changes-between-1-3-4-and-2-0-0
That means that the current load_entry_point mechanism is no longer working. With this small patch in test_runner.py
it should work again:
try:
entry_point = load_entry_point('py>=1.0.0', 'console_scripts', 'py.test')
except ImportError:
entry_point = load_entry_point('pytest>=2.0', 'console_scripts', 'py.test')
sys.exit(entry_point())
...site-packages/django_pytest/conftest.py:22:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.conf.LazySettings object at 0x21b2850>, name = 'DATABASE_NAME'
def __getattr__(self, name):
if self._wrapped is empty:
self._setup(name)
> return getattr(self._wrapped, name)
E AttributeError: 'Settings' object has no attribute 'DATABASE_NAME'
The user creation funcargs in conftest.py
isn't re-entrant. Second request raises an exception ending in this:
E IntegrityError: column username is not unique
I'll be returning with a pull request fixing this shortly.
Hello (again, I just made a pull request /w South support in it),
The line settings.DEBUG = False
is triggering a for me undesired behaviour in DjangoCMS. I'm wondering if you think it could be made optional, along these lines:
if not hasattr(settings, 'DEBUG'):
settings.DEBUG = False
If you think it's a good idea I can make another pull request with that change in it.
Cheers, and thanks for the library! /Jacob
Hi!
When I launch my application django, I get the following error:
DeprecationWarning: Function-based test runners are deprecated. Test runners should be classes with a run_tests() method.
DeprecationWarning
My configuration is:
Python 2.6.1
Django 1.3.1
Django-Pytest 0.1.5
Can you help me?
Thx.
Hey when trying to use django pytest plugin with the latest pep8 plugin I get the following error:
item = <Pep8Item 'some_file.py'>
def is_django_unittest(item):
"""
Returns True if the item is a Django test case, otherwise False.
"""
> return hasattr(item.obj, 'im_class') and issubclass(item.obj.im_class, DjangoBaseTestCase)
def get_django_unittest(item):
E AttributeError: 'Pep8Item' object has no attribute 'obj'
venv/lib/python2.7/site-packages/pytest_django/utils.py:32: AttributeError
It looks is_django_unittest assumes the item has an obj attribute, which maybe true for most tests but not for Pep8Items. I believe the fix is to update the logic of is_django_unittest to check for the presence of the obj attribute.
module versions for reference:
pytest==2.2.4
pytest-cache==0.9
pytest-cov==1.6
pytest-django==1.4
pytest-pep8==1.0.2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.