@@ -13,6 +13,9 @@ def setUp(self):
13
13
def tearDown (self ):
14
14
self .plugin_file .close ()
15
15
16
+ def _write_file (self , content ):
17
+ self .plugin_file .write (content .encode ('utf-8' ))
18
+
16
19
def test_load_empty_file (self ):
17
20
sut = PluginLoader ()
18
21
@@ -21,7 +24,7 @@ def test_load_empty_file(self):
21
24
self .assertEquals ({}, sut .plugins )
22
25
23
26
def test_base_case (self ):
24
- self .plugin_file . write ('class Foo(object): pass' )
27
+ self ._write_file ('class Foo(object): pass' )
25
28
self .plugin_file .flush ()
26
29
sut = PluginLoader ()
27
30
@@ -32,7 +35,7 @@ def test_base_case(self):
32
35
self .assertEquals ('Foo' , sut .plugins ['Foo' ]().__class__ .__name__ )
33
36
34
37
def test_ignorable_classes (self ):
35
- self .plugin_file . write ('class Foo(object): pass' )
38
+ self ._write_file ('class Foo(object): pass' )
36
39
self .plugin_file .flush ()
37
40
sut = PluginLoader ()
38
41
@@ -41,7 +44,7 @@ def test_ignorable_classes(self):
41
44
self .assertEquals ({}, sut .plugins )
42
45
43
46
def test_ignorable_classes_with_variable_false (self ):
44
- self .plugin_file . write ('class Foo(object): pass' )
47
+ self ._write_file ('class Foo(object): pass' )
45
48
self .plugin_file .flush ()
46
49
sut = PluginLoader ()
47
50
@@ -50,7 +53,7 @@ def test_ignorable_classes_with_variable_false(self):
50
53
self .assertEquals ([], sut .plugins .keys ())
51
54
52
55
def test_ignorable_classes_with_variable_true (self ):
53
- self .plugin_file . write ('class Foo(object): pass' )
56
+ self ._write_file ('class Foo(object): pass' )
54
57
self .plugin_file .flush ()
55
58
sut = PluginLoader ()
56
59
@@ -59,7 +62,7 @@ def test_ignorable_classes_with_variable_true(self):
59
62
self .assertItemsEqual (['__builtins__' , 'Foo' ], sut .plugins .keys ())
60
63
61
64
def test_parameters_for_constructor (self ):
62
- self .plugin_file . write (
65
+ self ._write_file (
63
66
'class Foo(object):\n '
64
67
' def __init__(self, a):\n '
65
68
' self.a = a'
@@ -73,7 +76,7 @@ def test_parameters_for_constructor(self):
73
76
self .assertEquals (5 , plugin .a )
74
77
75
78
def test_named_parameters_for_constructor (self ):
76
- self .plugin_file . write (
79
+ self ._write_file (
77
80
'class Foo(object):\n '
78
81
' def __init__(self, a):\n '
79
82
' self.a = a'
@@ -88,7 +91,7 @@ def test_named_parameters_for_constructor(self):
88
91
self .assertEquals (5 , plugin .a )
89
92
90
93
def test_two_plugins_in_a_file (self ):
91
- self .plugin_file . write (
94
+ self ._write_file (
92
95
'class Foo(object):\n '
93
96
' pass\n '
94
97
'class Bar(object):\n '
0 commit comments