diff --git a/django_pyvows/__init__.py b/django_pyvows/__init__.py index 43d9932..c55ac5c 100644 --- a/django_pyvows/__init__.py +++ b/django_pyvows/__init__.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # django-pyvows extensions diff --git a/django_pyvows/assertions.py b/django_pyvows/assertions.py index e918f0a..66153a0 100644 --- a/django_pyvows/assertions.py +++ b/django_pyvows/assertions.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # django-pyvows extensions diff --git a/django_pyvows/context.py b/django_pyvows/context.py index a772092..8ec90b9 100644 --- a/django_pyvows/context.py +++ b/django_pyvows/context.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # django-pyvows extensions @@ -20,15 +19,19 @@ from django_pyvows.settings_helpers import SettingsOverrideSupport class DjangoContext(Vows.Context, HttpClientSupport, SettingsOverrideSupport): def __init__(self, parent): super(DjangoContext, self).__init__(parent) + HttpClientSupport.__init__(self) SettingsOverrideSupport.__init__(self) - self.ignore('start_environment', 'settings_module') + + self.ignore('setup_environment', 'settings_module') + + DjangoContext.setup_environment(self.settings_module()) def settings_module(self): return 'settings' @classmethod - def start_environment(cls, settings_module): + def setup_environment(cls, settings_module): if not settings_module: raise ValueError('The settings_path argument is required.') diff --git a/django_pyvows/http_helpers.py b/django_pyvows/http_helpers.py index bd38466..dbafb16 100644 --- a/django_pyvows/http_helpers.py +++ b/django_pyvows/http_helpers.py @@ -1,6 +1,12 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- +# django-pyvows extensions +# https://github.com/rafaelcaricio/django-pyvows + +# Licensed under the MIT license: +# http://www.opensource.org/licenses/mit-license +# Copyright (c) 2011 Rafael Caricio rafael@caricio.com + class HttpClientSupport(object): def __init__(self): diff --git a/django_pyvows/settings_helpers.py b/django_pyvows/settings_helpers.py index 0b12389..243df4b 100644 --- a/django_pyvows/settings_helpers.py +++ b/django_pyvows/settings_helpers.py @@ -1,3 +1,11 @@ +# -*- coding: utf-8 -*- + +# django-pyvows extensions +# https://github.com/rafaelcaricio/django-pyvows + +# Licensed under the MIT license: +# http://www.opensource.org/licenses/mit-license +# Copyright (c) 2011 Rafael Caricio rafael@caricio.com class SettingsOverrideSupport(object): diff --git a/django_pyvows/version.py b/django_pyvows/version.py index 87442a9..3f7e054 100644 --- a/django_pyvows/version.py +++ b/django_pyvows/version.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # django-pyvows extensions diff --git a/vows/assertions_vows.py b/vows/assertions_vows.py index 067274c..fe39c72 100644 --- a/vows/assertions_vows.py +++ b/vows/assertions_vows.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # -*- coding: utf-8 -*- # django-pyvows extensions @@ -10,9 +9,7 @@ from pyvows import Vows, expect -from django_pyvows.context import DjangoContext - -DjangoContext.start_environment("sandbox.sandbox.settings") +from test_config import ConfiguredVowsContext as DjangoContext @Vows.batch diff --git a/vows/client_vows.py b/vows/client_vows.py index 1c9d0b3..7300a27 100644 --- a/vows/client_vows.py +++ b/vows/client_vows.py @@ -7,16 +7,10 @@ # Licensed under the MIT license: # http://www.opensource.org/licenses/mit-license # Copyright (c) 2011 Rafael Caricio rafael@caricio.com -from os.path import abspath, join, dirname from pyvows import Vows, expect -from django_pyvows.context import DjangoContext - - -TEST_FILE_PATH = abspath(join(dirname(__file__), 'fixtures/the_file.txt')) - -DjangoContext.start_environment("sandbox.sandbox.settings") +from test_config import ConfiguredVowsContext as DjangoContext @Vows.batch @@ -48,14 +42,14 @@ class DjangoHTTPTestClientCompatibilityVows(DjangoContext): class PostFile(DjangoContext): def topic(self): - return self.post('/post_file/', {'the_file': open(TEST_FILE_PATH)}) + return self.post('/post_file/', {'the_file': open(self.TEST_FILE_PATH)}) def should_be_posted_to_the_server(self, topic): expect(topic.content).to_equal("the contents") class WhenNotFound(DjangoContext): def topic(self): - return self.post('/post_/', {'the_file': open(TEST_FILE_PATH)}) + return self.post('/post_/', {'the_file': open(self.TEST_FILE_PATH)}) def should_be_404(self, topic): expect(topic.status_code).to_equal(404) diff --git a/vows/context_vows.py b/vows/context_vows.py index aa32940..48b3ea2 100644 --- a/vows/context_vows.py +++ b/vows/context_vows.py @@ -19,7 +19,7 @@ class ContextTest(Vows.Context): @capture_error def topic(self): - return DjangoContext.start_environment(None) + return DjangoContext.setup_environment(None) def should_be_an_error(self, topic): expect(topic).to_be_an_error() diff --git a/vows/settings_vows.py b/vows/settings_vows.py index b1f9f4c..827ad1f 100644 --- a/vows/settings_vows.py +++ b/vows/settings_vows.py @@ -11,9 +11,7 @@ from pyvows import Vows, expect from django.test.utils import override_settings -from django_pyvows.context import DjangoContext - -DjangoContext.start_environment("sandbox.sandbox.settings") +from test_config import ConfiguredVowsContext as DjangoContext @Vows.batch diff --git a/vows/test_config.py b/vows/test_config.py new file mode 100644 index 0000000..e557ccc --- /dev/null +++ b/vows/test_config.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- + +# django-pyvows extensions +# https://github.com/rafaelcaricio/django-pyvows + +# Licensed under the MIT license: +# http://www.opensource.org/licenses/mit-license +# Copyright (c) 2011 Rafael Caricio rafael@caricio.com + +from os.path import abspath, join, dirname + +from django_pyvows.context import DjangoContext + + +class ConfiguredVowsContext(DjangoContext): + def settings_module(self): + return 'sandbox.sandbox.settings' + + def setup(self): + self.TEST_FILE_PATH = abspath(join(dirname(__file__), 'fixtures/the_file.txt'))