Skip to content

Commit aa1919a

Browse files
committed
Added generic fixtures for testing
1 parent 66bd5f8 commit aa1919a

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

tests/amqp/test_extension.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
import asyncio
2-
import os
32

43
import pytest
54
from sage_utils.amqp.extension import AmqpExtension
65
from sage_utils.amqp.base import AmqpWorker
76

8-
9-
class FakeConfig(object):
10-
11-
def get(self, key, default=None):
12-
return os.environ.get(key, default)
13-
14-
15-
class Application(object):
16-
17-
def __init__(self, config=None):
18-
super(Application, self).__init__()
19-
self.config = config
7+
from tests.fixtures import Application, FakeConfig
208

219

2210
class CustomWorker(AmqpWorker):

tests/fixtures.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import os
2+
3+
4+
class FakeConfig(object):
5+
6+
def get(self, key, default=None):
7+
return os.environ.get(key, default)
8+
9+
10+
class Application(object):
11+
12+
def __init__(self, config=None):
13+
super(Application, self).__init__()
14+
self.config = config

tests/test_extension.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
from sage_utils.extension import BaseExtension
33

44

5-
class FakeConfig(object):
5+
from tests.fixtures import Application, FakeConfig as BaseFakeConfig
6+
7+
8+
class FakeConfig(BaseFakeConfig):
69
key = 'value'
710

811

@@ -11,13 +14,6 @@ class CustomExtension(BaseExtension):
1114
app_attribute = 'ext'
1215

1316

14-
class Application(object):
15-
16-
def __init__(self, config=None):
17-
super(Application, self).__init__()
18-
self.config = config
19-
20-
2117
def test_constructor_with_init():
2218
app = Application()
2319
extension = CustomExtension(app)

0 commit comments

Comments
 (0)