Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Make tests produce less chaotic output

Krzysiek Szularz95301d0138eb
diff --git a/payment/tests.py b/payment/tests.py
deleted file mode 100644
index 501deb776c..0000000000
--- a/payment/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/product/tests.py b/product/tests.py
deleted file mode 100644
index 501deb776c..0000000000
--- a/product/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/registration/models.py b/registration/models.py
index 42260226b2..4db64b282a 100644
--- a/registration/models.py
+++ b/registration/models.py
@@ -1,12 +1,14 @@
import os
-from datetime import datetime, timedelta
+from datetime import timedelta
from django.db import models
from django.contrib.auth import get_user_model
from django.conf import settings
+from django.utils import timezone
+
User = get_user_model()
-now = datetime.now
+now = timezone.now
class ExternalUserData(models.Model):
diff --git a/registration/tests.py b/registration/tests.py
index 13922c6c10..ed6fad1cb0 100644
--- a/registration/tests.py
+++ b/registration/tests.py
@@ -1,7 +1,8 @@
-import datetime
-
from django.contrib.auth import get_user_model
from django.test import TestCase
+from django.utils import timezone
+
+import datetime
from httpretty import HTTPretty, httprettified
from purl import URL
@@ -11,6 +12,7 @@ User = get_user_model()
class LoginViewTest(TestCase):
+
def setUp(self):
self.response = self.client.get('/account/login/')
@@ -227,7 +229,6 @@ class RegisterViewTest(TestCase):
self.assertTrue(EmailConfirmation.objects.filter(email=email).exists())
def test_register_with_extrnally_confirmed_email_and_no_extern_login(self):
-
# if we don't impose some action for TestClient we shall not be able to
# set variables to session
self.client.get('/')
@@ -251,7 +252,6 @@ class RegisterViewTest(TestCase):
self.assertFalse('confirmed_email' in self.client.session)
def test_register_with_externally_confirmed_email(self):
-
# if we don't impose some action for TestClient we shall not be able to
# set variables to session
self.client.get('/')
@@ -279,7 +279,6 @@ class RegisterViewTest(TestCase):
EmailConfirmation.objects.count())
def test_register_from_external_provider_and_change_email(self):
-
# if we don't impose some action for TestClient we shall not be able to
# set variables to session
self.client.get('/')
@@ -419,9 +418,10 @@ class ConfirmationEmailTest(TestCase):
self.assertFalse(User.objects.filter(email=email).exists())
- ec = EmailConfirmation.objects.create(email=email)
- ec.valid_until = datetime.datetime(1970, 1, 1, 12, 0)
- ec.save()
+ valid_until = timezone.now() - datetime.timedelta(days=1)
+
+ ec = EmailConfirmation.objects.create(email=email,
+ valid_until=valid_until)
response = self.client.post(
'/account/confirm_email/%s/%s/' % (ec.id, ec.token),
diff --git a/registration/views.py b/registration/views.py
index 7882dd270f..9e85cee6cf 100644
--- a/registration/views.py
+++ b/registration/views.py
@@ -1,5 +1,3 @@
-from django.utils import timezone
-
from django.contrib.auth.views import (
login as django_login_view,
logout as django_logout,
@@ -15,6 +13,7 @@ from django.core.mail.message import EmailMessage
from django.http import HttpResponseNotFound, HttpResponseBadRequest
from django.shortcuts import redirect
from django.template.response import TemplateResponse
+from django.utils import timezone
from .forms import LoginForm, EmailForm, EmailConfirmationFormset
from .models import ExternalUserData, EmailConfirmation
diff --git a/setup.cfg b/setup.cfg
deleted file mode 100644
index 9928f3a0b0..0000000000
--- a/setup.cfg
+++ /dev/null
@@ -1,7 +0,0 @@
-[nosetests]
-verbosity=2
-with-coverage=1
-with-doctest=1
-cover-branches=1
-cover-erase=1
-cover-package=saleor, product, registration
diff --git a/setup.py b/setup.py
index 4918152836..c725c532b1 100755
--- a/setup.py
+++ b/setup.py
@@ -1,17 +1,10 @@
#! /usr/bin/env python
from setuptools import setup, find_packages, Command
-from setuptools.command.test import test
import os
-
os.environ['DJANGO_SETTINGS_MODULE'] = 'saleor.settings'
-class Test(test):
- def run(self):
- return test.run(self)
-
-
class Command(Command):
user_options = []
initialize_options = lambda self: None
@@ -43,7 +36,7 @@ setup(
'oauth2client>=1.1',
'httplib2>=0.8',
'purl>=0.4.1',
- "facebook-sdk>=0.4.0"],
+ 'facebook-sdk>=0.4.0'],
extras_require={
'lint': ['pylint==0.26.0', 'django-lint==dev']},
dependency_links=[
@@ -52,11 +45,9 @@ setup(
entry_points={
'console_scripts': ['saleor = saleor:manage']},
cmdclass={
- 'lint': Lint,
- 'test': Test},
+ 'lint': Lint},
tests_require=[
- 'coverage==3.6',
'mock==1.0.1',
'httpretty>=0.5.10',
- 'nose==1.2.1'],
- test_suite='nose.collector')
+ 'discover==0.4.0'],
+ test_suite='discover.collector')
diff --git a/userprofile/models.py b/userprofile/models.py
index f09eea8b72..15fe8cb9e9 100644
--- a/userprofile/models.py
+++ b/userprofile/models.py
@@ -7,8 +7,8 @@ from django.contrib.auth.hashers import (check_password, make_password,
is_password_usable)
from django.contrib.auth.models import BaseUserManager
from django.db import models
-from django.utils.translation import ugettext_lazy
from django.utils import timezone
+from django.utils.translation import ugettext_lazy
from saleor.countries import COUNTRY_CHOICES