77from freshen .core import load_language
88from freshen .parser import parse_file
99
10+ import os
11+
1012class TestParseValidFeature (unittest .TestCase ):
1113 """
1214 Tests for the parsing of a valid feature.
1315 """
14-
16+
1517 def setUp (self ):
1618 self .language = load_language ('en' )
19+ self .cur_dir = os .path .dirname (os .path .abspath (__file__ ))
20+
1721
18-
1922 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 )
2124 self .assertEquals (feature .name , 'Independence of the counter.' )
22-
23-
25+
26+
2427 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 )
2629 self .assertEquals (feature .tags [0 ], 'one' )
27-
28-
30+
31+
2932 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 )
3134 self .assertEquals (feature .use_step_defs [0 ], 'independent_one' )
32-
33-
35+
36+
3437 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 )
3639 self .assertEquals (feature .use_step_defs [0 ], 'independent_one' )
3740 self .assertEquals (feature .use_step_defs [1 ], 'te st' )
38-
39-
41+
42+
4043 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 )
4245 self .assertEquals (feature .tags [0 ], 'one' )
4346 self .assertEquals (feature .use_step_defs [0 ], 'independent_one' )
44-
45-
47+
48+
4649 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 )
4851 self .assertEquals (feature .tags [0 ], 'one' )
4952 self .assertEquals (feature .use_step_defs [0 ], 'independent_one' )
5053 self .assertEquals (feature .use_step_defs [1 ], 'te st' )
51-
52-
54+
55+
5356 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 )
5558 self .assertEquals (feature .tags [0 ], 'one' )
5659 self .assertEquals (feature .use_step_defs [0 ], 'unicodeèédç' )
57-
60+
5861
5962 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 )
6164 self .assertEquals (feature .tags [0 ], 'one' )
6265 self .assertEquals (feature .use_step_defs [0 ], '/home/user/independent_one.py' )
6366
6467
6568 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 )
6770 self .assertEquals (feature .tags [0 ], 'one' )
6871 self .assertEquals (feature .use_step_defs [0 ], 'C:\\ Documents and Settings\\ user\\ Desktop\\ independent_one.py' )
69-
70-
72+
73+
7174 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 )
7376 self .assertEquals (feature .use_step_defs [0 ], 'independent_one' )
74-
75-
77+
78+
7679 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 )
7881 self .assertTrue (feature .has_background ())
7982 self .assertEquals (len (feature .background .steps ), 2 )
8083 self .assertEquals (len (feature .scenarios ), 2 )
81-
82-
84+
85+
8386 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 )
8588 self .assertTrue (feature .has_background ())
8689 self .assertEquals (len (feature .background .steps ), 2 )
8790 self .assertEquals (len (feature .scenarios ), 2 )
8891 self .assertEquals (len (feature .scenarios [0 ].tags ), 1 )
89-
90-
92+
93+
9194 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 )
9396 self .assertTrue (feature .has_background ())
9497 self .assertEquals (len (feature .background .steps ), 2 )
9598 self .assertEquals (len (feature .scenarios ), 2 )
9699 self .assertEquals (len (feature .scenarios [0 ].tags ), 1 )
97-
100+
98101
99102class TestParseValidFeatureInFrench (unittest .TestCase ):
100103 """
101104 Tests for the parsing of a valid feature in French.
102105 """
103-
106+
104107 def setUp (self ):
105108 self .language = load_language ('fr' )
109+ self .cur_dir = os .path .dirname (os .path .abspath (__file__ ))
110+
106111
107-
108112 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 )
110114 self .assertEquals (feature .name , "L'indépendance des compteurs." )
111-
112-
115+
116+
113117 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 )
115119 self .assertEquals (feature .tags [0 ], 'un' )
116-
117-
120+
121+
118122 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 )
120124 self .assertEquals (feature .use_step_defs [0 ], 'independent_one' )
121-
122-
125+
126+
123127 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 )
125129 self .assertEquals (feature .use_step_defs [0 ], 'independent_one' )
126130
127131
128132 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 )
130134 self .assertTrue (feature .has_background ())
131135 self .assertEquals (len (feature .background .steps ), 2 )
132136 self .assertEquals (len (feature .scenarios ), 2 )
@@ -135,21 +139,22 @@ def test_should_parse_feature_file_with_background_and_no_tags_fr(self):
135139class TestParseValidFeatureInBulgarian (unittest .TestCase ):
136140 """
137141 Tests for the parsing of a valid feature in Bulgarian.
138-
142+
139143 @note: This test is used to ensure that if a keyword is not translated
140144 in a given language, then the missing keyword can be spelled in English.
141145 """
142-
146+
143147 def setUp (self ):
144148 self .language = load_language ('bg' )
149+ self .cur_dir = os .path .dirname (os .path .abspath (__file__ ))
150+
145151
146-
147152 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 )
149154 self .assertEquals (feature .tags [0 ], 'one' )
150155 self .assertEquals (feature .use_step_defs [0 ], 'independent_one' )
151156 self .assertEquals (feature .use_step_defs [1 ], 'te st' )
152157
153-
158+
154159if __name__ == "__main__" :
155160 unittest .main ()
0 commit comments