7
7
from freshen .core import load_language
8
8
from freshen .parser import parse_file
9
9
10
+ import os
11
+
10
12
class TestParseValidFeature (unittest .TestCase ):
11
13
"""
12
14
Tests for the parsing of a valid feature.
13
15
"""
14
-
16
+
15
17
def setUp (self ):
16
18
self .language = load_language ('en' )
19
+ self .cur_dir = os .path .dirname (os .path .abspath (__file__ ))
20
+
17
21
18
-
19
22
def test_should_parse_feature_file_without_tags_and_without_use_only (self ):
20
- feature = parse_file (' resources/valid_no_tags_no_use_only.feature' , self .language )
23
+ feature = parse_file (self . cur_dir + '/ resources/valid_no_tags_no_use_only.feature' , self .language )
21
24
self .assertEquals (feature .name , 'Independence of the counter.' )
22
-
23
-
25
+
26
+
24
27
def test_should_parse_feature_file_with_tags_and_without_use_only (self ):
25
- feature = parse_file (' resources/valid_with_tags_no_use_only.feature' , self .language )
28
+ feature = parse_file (self . cur_dir + '/ resources/valid_with_tags_no_use_only.feature' , self .language )
26
29
self .assertEquals (feature .tags [0 ], 'one' )
27
-
28
-
30
+
31
+
29
32
def test_should_parse_feature_file_without_tags_and_with_use_only (self ):
30
- feature = parse_file (' resources/valid_no_tags_with_use_only.feature' , self .language )
33
+ feature = parse_file (self . cur_dir + '/ resources/valid_no_tags_with_use_only.feature' , self .language )
31
34
self .assertEquals (feature .use_step_defs [0 ], 'independent_one' )
32
-
33
-
35
+
36
+
34
37
def test_should_parse_feature_file_without_tags_and_with_multiple_use_only (self ):
35
- feature = parse_file (' resources/valid_no_tags_with_multiple_use_only.feature' , self .language )
38
+ feature = parse_file (self . cur_dir + '/ resources/valid_no_tags_with_multiple_use_only.feature' , self .language )
36
39
self .assertEquals (feature .use_step_defs [0 ], 'independent_one' )
37
40
self .assertEquals (feature .use_step_defs [1 ], 'te st' )
38
-
39
-
41
+
42
+
40
43
def test_should_parse_feature_file_with_tags_and_with_use_only (self ):
41
- feature = parse_file (' resources/valid_with_tags_with_use_only.feature' , self .language )
44
+ feature = parse_file (self . cur_dir + '/ resources/valid_with_tags_with_use_only.feature' , self .language )
42
45
self .assertEquals (feature .tags [0 ], 'one' )
43
46
self .assertEquals (feature .use_step_defs [0 ], 'independent_one' )
44
-
45
-
47
+
48
+
46
49
def test_should_parse_feature_file_with_tags_and_with_multiple_use_only (self ):
47
- feature = parse_file (' resources/valid_with_tags_with_multiple_use_only.feature' , self .language )
50
+ feature = parse_file (self . cur_dir + '/ resources/valid_with_tags_with_multiple_use_only.feature' , self .language )
48
51
self .assertEquals (feature .tags [0 ], 'one' )
49
52
self .assertEquals (feature .use_step_defs [0 ], 'independent_one' )
50
53
self .assertEquals (feature .use_step_defs [1 ], 'te st' )
51
-
52
-
54
+
55
+
53
56
def test_should_parse_feature_file_with_unicode_use_only (self ):
54
- feature = parse_file (' resources/valid_with_tags_with_unicode_use_only.feature' , self .language )
57
+ feature = parse_file (self . cur_dir + '/ resources/valid_with_tags_with_unicode_use_only.feature' , self .language )
55
58
self .assertEquals (feature .tags [0 ], 'one' )
56
59
self .assertEquals (feature .use_step_defs [0 ], 'unicodeèédç' )
57
-
60
+
58
61
59
62
def test_should_parse_feature_file_with_full_unix_path_use_only (self ):
60
- feature = parse_file (' resources/valid_with_tags_with_full_unix_path_use_only.feature' , self .language )
63
+ feature = parse_file (self . cur_dir + '/ resources/valid_with_tags_with_full_unix_path_use_only.feature' , self .language )
61
64
self .assertEquals (feature .tags [0 ], 'one' )
62
65
self .assertEquals (feature .use_step_defs [0 ], '/home/user/independent_one.py' )
63
66
64
67
65
68
def test_should_parse_feature_file_with_full_windows_path_use_only (self ):
66
- feature = parse_file (' resources/valid_with_tags_with_full_windows_path_use_only.feature' , self .language )
69
+ feature = parse_file (self . cur_dir + '/ resources/valid_with_tags_with_full_windows_path_use_only.feature' , self .language )
67
70
self .assertEquals (feature .tags [0 ], 'one' )
68
71
self .assertEquals (feature .use_step_defs [0 ], 'C:\\ Documents and Settings\\ user\\ Desktop\\ independent_one.py' )
69
-
70
-
72
+
73
+
71
74
def test_should_parse_feature_file_with_use_only_short_form (self ):
72
- feature = parse_file (' resources/valid_no_tags_with_use_only_short_form.feature' , self .language )
75
+ feature = parse_file (self . cur_dir + '/ resources/valid_no_tags_with_use_only_short_form.feature' , self .language )
73
76
self .assertEquals (feature .use_step_defs [0 ], 'independent_one' )
74
-
75
-
77
+
78
+
76
79
def test_should_parse_feature_file_with_background_and_no_tags (self ):
77
- feature = parse_file (' resources/Befriend_without_tags.feature' , self .language )
80
+ feature = parse_file (self . cur_dir + '/ resources/Befriend_without_tags.feature' , self .language )
78
81
self .assertTrue (feature .has_background ())
79
82
self .assertEquals (len (feature .background .steps ), 2 )
80
83
self .assertEquals (len (feature .scenarios ), 2 )
81
-
82
-
84
+
85
+
83
86
def test_should_parse_feature_file_with_background_and_tags (self ):
84
- feature = parse_file (' resources/Befriend_with_tags.feature' , self .language )
87
+ feature = parse_file (self . cur_dir + '/ resources/Befriend_with_tags.feature' , self .language )
85
88
self .assertTrue (feature .has_background ())
86
89
self .assertEquals (len (feature .background .steps ), 2 )
87
90
self .assertEquals (len (feature .scenarios ), 2 )
88
91
self .assertEquals (len (feature .scenarios [0 ].tags ), 1 )
89
-
90
-
92
+
93
+
91
94
def test_should_parse_feature_file_with_background_and_title_and_tags (self ):
92
- feature = parse_file (' resources/Befriend_with_tags_and_background_title.feature' , self .language )
95
+ feature = parse_file (self . cur_dir + '/ resources/Befriend_with_tags_and_background_title.feature' , self .language )
93
96
self .assertTrue (feature .has_background ())
94
97
self .assertEquals (len (feature .background .steps ), 2 )
95
98
self .assertEquals (len (feature .scenarios ), 2 )
96
99
self .assertEquals (len (feature .scenarios [0 ].tags ), 1 )
97
-
100
+
98
101
99
102
class TestParseValidFeatureInFrench (unittest .TestCase ):
100
103
"""
101
104
Tests for the parsing of a valid feature in French.
102
105
"""
103
-
106
+
104
107
def setUp (self ):
105
108
self .language = load_language ('fr' )
109
+ self .cur_dir = os .path .dirname (os .path .abspath (__file__ ))
110
+
106
111
107
-
108
112
def test_should_parse_feature_file_without_tags_and_without_use_only (self ):
109
- feature = parse_file (' resources/valid_no_tags_no_use_only_fr.feature' , self .language )
113
+ feature = parse_file (self . cur_dir + '/ resources/valid_no_tags_no_use_only_fr.feature' , self .language )
110
114
self .assertEquals (feature .name , "L'indépendance des compteurs." )
111
-
112
-
115
+
116
+
113
117
def test_should_parse_feature_file_with_tags_and_without_use_only (self ):
114
- feature = parse_file (' resources/valid_with_tags_no_use_only_fr.feature' , self .language )
118
+ feature = parse_file (self . cur_dir + '/ resources/valid_with_tags_no_use_only_fr.feature' , self .language )
115
119
self .assertEquals (feature .tags [0 ], 'un' )
116
-
117
-
120
+
121
+
118
122
def test_should_parse_feature_file_without_tags_and_with_use_only (self ):
119
- feature = parse_file (' resources/valid_no_tags_with_use_only_fr.feature' , self .language )
123
+ feature = parse_file (self . cur_dir + '/ resources/valid_no_tags_with_use_only_fr.feature' , self .language )
120
124
self .assertEquals (feature .use_step_defs [0 ], 'independent_one' )
121
-
122
-
125
+
126
+
123
127
def test_should_parse_feature_file_with_use_only_short_form_fr (self ):
124
- feature = parse_file (' resources/valid_no_tags_with_use_only_short_form_fr.feature' , self .language )
128
+ feature = parse_file (self . cur_dir + '/ resources/valid_no_tags_with_use_only_short_form_fr.feature' , self .language )
125
129
self .assertEquals (feature .use_step_defs [0 ], 'independent_one' )
126
130
127
131
128
132
def test_should_parse_feature_file_with_background_and_no_tags_fr (self ):
129
- feature = parse_file (' resources/Befriend_without_tags_fr.feature' , self .language )
133
+ feature = parse_file (self . cur_dir + '/ resources/Befriend_without_tags_fr.feature' , self .language )
130
134
self .assertTrue (feature .has_background ())
131
135
self .assertEquals (len (feature .background .steps ), 2 )
132
136
self .assertEquals (len (feature .scenarios ), 2 )
@@ -135,21 +139,22 @@ def test_should_parse_feature_file_with_background_and_no_tags_fr(self):
135
139
class TestParseValidFeatureInBulgarian (unittest .TestCase ):
136
140
"""
137
141
Tests for the parsing of a valid feature in Bulgarian.
138
-
142
+
139
143
@note: This test is used to ensure that if a keyword is not translated
140
144
in a given language, then the missing keyword can be spelled in English.
141
145
"""
142
-
146
+
143
147
def setUp (self ):
144
148
self .language = load_language ('bg' )
149
+ self .cur_dir = os .path .dirname (os .path .abspath (__file__ ))
150
+
145
151
146
-
147
152
def test_should_parse_feature_file_with_tags_and_with_multiple_use_only (self ):
148
- feature = parse_file (' resources/valid_with_tags_with_multiple_use_only_bg.feature' , self .language )
153
+ feature = parse_file (self . cur_dir + '/ resources/valid_with_tags_with_multiple_use_only_bg.feature' , self .language )
149
154
self .assertEquals (feature .tags [0 ], 'one' )
150
155
self .assertEquals (feature .use_step_defs [0 ], 'independent_one' )
151
156
self .assertEquals (feature .use_step_defs [1 ], 'te st' )
152
157
153
-
158
+
154
159
if __name__ == "__main__" :
155
160
unittest .main ()
0 commit comments