Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Start using pytest
Patryk Zawadzkiacd037df17e4
diff --git a/pytest.ini b/pytest.ininew file mode 100644index 0000000000..4345aed91e--- /dev/null+++ b/pytest.ini@@ -0,0 +1,2 @@+[pytest]+DJANGO_SETTINGS_MODULE=saleor.test_settingsdiff --git a/saleor/cart/tests.py b/saleor/cart/test_cart.pysimilarity index 98%rename from saleor/cart/tests.pyrename to saleor/cart/test_cart.pyindex cd40e2268b..16c0b5c3a7 100755--- a/saleor/cart/tests.py+++ b/saleor/cart/test_cart.py@@ -16,7 +16,7 @@ __all__ = ['CartTest', 'BigShipCartFormTest']class BigShip(ProductVariant, StockedProduct, PhysicalProduct):- name = models.CharField()+ name = models.CharField(max_length=250)def get_price_per_item(self, discounted=True, **kwargs):return self.price@@ -26,7 +26,7 @@ class BigShip(ProductVariant, StockedProduct, PhysicalProduct):class ShipPhoto(ProductVariant, PhysicalProduct):- name = models.CharField()+ name = models.CharField(max_length=250)def get_slug(self):return 'bigship-photo'diff --git a/saleor/checkout/tests.py b/saleor/checkout/test_checkout.pysimilarity index 100%rename from saleor/checkout/tests.pyrename to saleor/checkout/test_checkout.pydiff --git a/saleor/core/tests.py b/saleor/core/test_core.pysimilarity index 96%rename from saleor/core/tests.pyrename to saleor/core/test_core.pyindex cedf5945b4..19b1ae85e3 100644--- a/saleor/core/tests.py+++ b/saleor/core/test_core.py@@ -1,5 +1,6 @@+from unittest import TestCase+from django.template.response import TemplateResponse-from django.test import TestCasefrom mock import MagicMockfrom satchless.process import InvalidDatadiff --git a/saleor/order/tests.py b/saleor/order/test_order.pysimilarity index 100%rename from saleor/order/tests.pyrename to saleor/order/test_order.pydiff --git a/saleor/registration/tests.py b/saleor/registration/test_registration.pysimilarity index 100%rename from saleor/registration/tests.pyrename to saleor/registration/test_registration.pydiff --git a/saleor/tests.py b/saleor/tests.pydeleted file mode 100644index 9286175753..0000000000--- a/saleor/tests.py+++ /dev/null@@ -1,22 +0,0 @@-from unittest import TestSuite, TestLoader--import django--if hasattr(django, 'setup'):- django.setup()--TEST_MODULES = [- 'saleor.cart.tests',- 'saleor.checkout.tests',- 'saleor.core.tests',- #'saleor.delivery.tests',- 'saleor.order.tests',- #'saleor.payment.tests',- #'saleor.product.tests',- 'saleor.registration.tests',- 'saleor.userprofile.tests']--suite = TestSuite()-loader = TestLoader()-for module in TEST_MODULES:- suite.addTests(loader.loadTestsFromName(module))diff --git a/saleor/userprofile/tests.py b/saleor/userprofile/tests.pydeleted file mode 100755index 501deb776c..0000000000--- a/saleor/userprofile/tests.py+++ /dev/null@@ -1,16 +0,0 @@-"""-This file demonstrates writing tests using the unittest module. These will pass-when you run "manage.py test".--Replace this with more appropriate tests for your application.-"""--from django.test import TestCase---class SimpleTest(TestCase):- def test_basic_addition(self):- """- Tests that 1 + 1 always equals 2.- """- self.assertEqual(1 + 1, 2)diff --git a/setup.py b/setup.pyindex b0c4f7d3b7..4cd511b771 100755--- a/setup.py+++ b/setup.py@@ -1,9 +1,31 @@#! /usr/bin/env pythonfrom setuptools import setup, find_packages+from setuptools.command.test import test as TestCommandimport os+import sysos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'saleor.settings')++class PyTest(TestCommand):+ user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]++ def initialize_options(self):+ TestCommand.initialize_options(self)+ self.pytest_args = []++ def finalize_options(self):+ TestCommand.finalize_options(self)+ self.test_args = []+ self.test_suite = True++ def run_tests(self):+ #import here, cause outside the eggs aren't loaded+ import pytest+ errno = pytest.main(self.pytest_args)+ sys.exit(errno)++setup(name='saleor',author='Mirumee Software',@@ -33,20 +55,18 @@ setup('prices>=0.5,<0.6a0','requests>=1.2.0','satchless>=1.1.2,<1.2a0',- 'unidecode'- ],+ 'unidecode'],extras_require={'PaaS': ['whitenoise==1.0.6','gunicorn==19.2.1',- 'psycopg2==2.6',- ]- },+ 'psycopg2==2.6']},+ cmdclass={+ 'test': PyTest},entry_points={'console_scripts': ['saleor = saleor:manage']},tests_require=['mock==1.0.1','purl>=0.4.1',- ],- test_suite='saleor.tests.suite'-)+ 'pytest',+ 'pytest-django'])diff --git a/tox.ini b/tox.ininew file mode 100644index 0000000000..e52640ac7a--- /dev/null+++ b/tox.ini@@ -0,0 +1,10 @@+[tox]+envlist = py27,py33,py34++[testenv]+deps=+ mock+ purl+ pytest+ pytest-django+commands=py.test