Skip to content

Commit bc96323

Browse files
authored
Merge pull request #24 from thraxil/relative-imports
switch to relative import
2 parents f52533a + 19b6b95 commit bc96323

File tree

7 files changed

+34
-21
lines changed

7 files changed

+34
-21
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ install:
1616
- pip install flake8
1717
- pip install coveralls
1818
script:
19-
- flake8 smoketest
19+
- flake8 smoketest exceptionstest main testapp
2020
- python runtests.py
2121
- coverage run --source=smoketest runtests.py
2222
after_success:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ test:
33
virtualenv ve
44
./ve/bin/pip install .
55
./ve/bin/pip install flake8
6-
./ve/bin/flake8 smoketest --max-complexity=9
6+
./ve/bin/flake8 smoketest exceptionstest main testapp --max-complexity=9
77
./ve/bin/python runtests.py
88

99
clean:

exceptionstest/smoke.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
from smoketest import SmokeTest
22
from exceptionstest import EXC_MSG
33

4-
5-
6-
# raise exception here so we can test what will happen when we got any exception
7-
# from smoke.py file
8-
raise Exception(EXC_MSG)
9-
4+
# raise exception here so we can test what will happen when
5+
# we got any exception from smoke.py file
6+
raise Exception(EXC_MSG)
107

118

129
class TestSmokeTestWithExceptions(SmokeTest):

main/tests.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ class BasicTest(TestCase):
1616
class TestWithException(SmokeTest):
1717
def test_fail(self):
1818
self.assertTrue(False, BasicTest._FAIL_MSG)
19+
1920
def test_with_exception(self):
2021
raise Exception(BasicTest._EXC_MSG)
22+
2123
def dir(self):
2224
""" Overvrite dir method so test_fail would be before
2325
test_with_exception for sure.
2426
2527
"""
2628
return ['test_fail', 'test_with_exception']
2729

28-
2930
def setUp(self):
3031
settings.INSTALLED_APPS = ('main', 'smoketest')
3132
self.c = Client()
@@ -52,6 +53,10 @@ def test_basics(self):
5253
TestFailedSmokeTests.CUSTOM_TEST_MSG,
5354
response.content.decode('utf-8'))
5455

56+
def test_extendable(self):
57+
response = self.c.get("/extendable/")
58+
self.assertEqual(response.status_code, 500)
59+
5560
def test_json(self):
5661
" Testing JSON response. "
5762
json_content_type = 'application/json'
@@ -77,7 +82,6 @@ def test_json(self):
7782
TestFailedSmokeTests.CUSTOM_TEST_MSG,
7883
response_obj['failed_tests'])
7984

80-
8185
def test_error(self):
8286
" Tests the error case (when we got exception during the smoke test). "
8387
test = self.TestWithException()
@@ -86,14 +90,14 @@ def test_error(self):
8690
self.assertEqual(1, errored)
8791
self.assertEqual(errored, len(e_tests))
8892
self.assertIn(
89-
"TestWithException.test_with_exception errored: %s" %
90-
BasicTest._EXC_MSG,
91-
e_tests[0])
93+
"TestWithException.test_with_exception errored: %s" %
94+
BasicTest._EXC_MSG,
95+
e_tests[0])
9296
self.assertNotIn(BasicTest._FAIL_MSG, e_tests[0])
9397

94-
9598
def test_logging(self):
96-
" On failure and on errors, messages should be logged by setup method. "
99+
""" On failure and on errors, messages should be logged by setup method.
100+
"""
97101
_logged_msgs = []
98102

99103
def logger_mock(msg):
@@ -108,13 +112,13 @@ def __init__(self):
108112

109113
TestForLogging().run()
110114

111-
# After this, both fail and error message should be logged (should be in
112-
# _looged_msgs array).
115+
# After this, both fail and error message should be logged
116+
# (should be in _looged_msgs array).
113117
self.assertEqual(2, len(_logged_msgs))
114118
# As stated in TestWithException, the fake test will be the first for
115119
# sure.
116120
self.assertIn(BasicTest._FAIL_MSG, _logged_msgs[0])
117121
self.assertIn(
118-
"TestForLogging.test_with_exception errored: %s" %
119-
BasicTest._EXC_MSG,
120-
_logged_msgs[1])
122+
"TestForLogging.test_with_exception errored: %s" %
123+
BasicTest._EXC_MSG,
124+
_logged_msgs[1])

smoketest/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import inspect
88
import importlib
99
import time
10-
from smoketest import SmokeTest, ApplicationTestResultSet
10+
from . import SmokeTest, ApplicationTestResultSet
1111

1212

1313
def test_class(cls):

testapp/urls.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
except ImportError:
44
from django.conf.urls.defaults import include, url
55

6+
from .views import TestView
7+
68
urlpatterns = [
79
url('^smoketest/$', include('smoketest.urls')),
10+
url('^extendable/$', TestView.as_view()),
811
]

testapp/views.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""
2+
Just make sure that the main view is extendable
3+
"""
4+
5+
from smoketest.views import IndexView
6+
7+
8+
class TestView(IndexView):
9+
pass

0 commit comments

Comments
 (0)