Skip to content

Commit b3fef2a

Browse files
author
Pipeline
committed
R upgrade from python 2 to python 3, which caused file path modifications
1 parent efbd002 commit b3fef2a

File tree

8 files changed

+22
-20
lines changed

8 files changed

+22
-20
lines changed

Infrastructure/TipsManager.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77

88
class TipsManager(object):
99
def __init__(self, seed=None, root_directory=sys.argv[0]):
10-
self.root_directory = "/".join(root_directory.split('/')[:-1])
10+
self.root_directory = self.go_up_dir(root_directory)
1111
if seed is not None:
1212
random.seed(seed)
1313

14+
def go_up_dir(self, root_directory):
15+
return "/".join(root_directory.split('/')[:-1])
16+
1417
def get_random_tip(self):
1518
tips_folder = self.root_directory + "/Tips"
1619
random_file = random.choice(os.listdir("%s" % tips_folder))

tests/Infrastructure/CountdownManager/test_CountdownManager.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import datetime
2-
import time
31
import unittest
42

53
from approvaltests.approvals import verify
64

75
from Infrastructure.CountdownManager import CountdownManager
86

97

10-
class test_CountdownManager(unittest.TestCase):
8+
class TestsCountdownManager(unittest.TestCase):
119

1210
def test_set_countdown_timer(self):
1311
countdown_manager = CountdownManager(None)

tests/Infrastructure/CountdownManager/test_CountdownManager.test_subscribe_to_time_changes.approved.txt

Whitespace-only changes.

tests/Infrastructure/MobberManager/TestsMobberManager.py renamed to tests/Infrastructure/MobberManager/test_MobberManager.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
import os
21
import random
32
import unittest
4-
from approvaltests import Approvals
5-
from approvaltests.GenericDiffReporterFactory import GenericDiffReporterFactory
3+
from approvaltests.approvals import verify
64
from Infrastructure.MobberManager import MobberManager
75

86

97
class TestsMobberManager(unittest.TestCase):
10-
def setUp(self):
11-
self.reporter = GenericDiffReporterFactory().get_first_working()
12-
138
def test_empty_mobber_manager_has_no_items(self):
149
mobber_manager = MobberManager()
1510
self.assertEqual(mobber_manager.mobber_count(), 0)
@@ -148,7 +143,7 @@ def time_change_callback(mobber_list, driver_index, navigator_index):
148143
mobber_manager.remove_mobber(0)
149144
mobber_manager.remove_mobber(0)
150145

151-
Approvals.verify(result["result"], self.reporter)
146+
verify(result["result"])
152147

153148
def test_subscribe_to_mobber_list_changes_random(self):
154149
random.seed(0)
@@ -193,7 +188,7 @@ def time_change_callback(mobber_list, driver_index, navigator_index):
193188
mobber_manager.remove_mobber(0)
194189
mobber_manager.remove_mobber(0)
195190

196-
Approvals.verify(result["result"], self.reporter)
191+
verify(result["result"])
197192

198193
def test_navigator1_driver0_index(self):
199194
mobber_manager = MobberManager()

tests/Infrastructure/SessionManager/TestsSessionManager.py renamed to tests/Infrastructure/SessionManager/test_SessionManager.py

File renamed without changes.

tests/Infrastructure/TimeOptionsManager/TestsTimeOptionsManager.test_subscribe_to_time_changes_complex.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ Time Options after Change:
1414
Change 13| 11:45
1515
Change 14| 12:45
1616
Change 15| 13:45
17-
Change 16| 03:14
17+
Change 16| 03:14

tests/Infrastructure/TimeOptionsManager/TestsTimeOptionsManager.py renamed to tests/Infrastructure/TimeOptionsManager/test_TimeOptionsManager.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import os
22
import unittest
33

4-
from approvaltests import Approvals
5-
from approvaltests.GenericDiffReporterFactory import GenericDiffReporterFactory
4+
from approvaltests.approvals import verify
65

76
from Infrastructure.TimeSettingsManager import TimeSettingsManager
87

98

109
class TestsTimeOptionsManager(unittest.TestCase):
11-
def setUp(self):
12-
self.reporter = GenericDiffReporterFactory().get_first_working()
1310

1411
def test_default_time_10_minutes(self):
1512
time_options_manager = TimeSettingsManager()
@@ -96,7 +93,7 @@ def time_change_callback(time, minutes, seconds,origin_station_name):
9693
time_options_manager.increment_minutes()
9794
time_options_manager.set_countdown_time(3, 14)
9895

99-
Approvals.verify(result["result"], self.reporter)
96+
verify(result["result"])
10097

10198
if __name__ == '__main__':
10299
os.environ["APPROVALS_TEXT_DIFF_TOOL"] = "meld"

tests/Infrastructure/TipsManager/TestTipsManager.py renamed to tests/Infrastructure/TipsManager/test_TipsManager.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,28 @@
22

33
import sys
44

5+
import os
56
from Infrastructure.TipsManager import TipsManager
67

78

89
class TestsTipsManage(unittest.TestCase):
910
def test_random_tip_from_file(self):
1011
seed = 0
11-
tips_manager = TipsManager(seed,sys.path[1])
12+
13+
dirname = os.path.dirname(__file__)
14+
path = self.go_two_dirs_up(dirname) + "/Tips"
15+
tips_manager = TipsManager(seed, path)
1216
result = tips_manager.get_random_tip()
1317
self.assertEqual(result, 'TestTips2.txt: Words\n')
1418

19+
def go_two_dirs_up(self, dirname):
20+
return "/".join(dirname.split('\\')[:-2])
21+
1522
def test_random_tip_from_file_second(self):
1623
seed = 1
17-
tips_manager = TipsManager(seed,sys.path[1])
24+
dirname = os.path.dirname(__file__)
25+
path = self.go_two_dirs_up(dirname) + "/Tips"
26+
tips_manager = TipsManager(seed, path)
1827
result = tips_manager.get_random_tip()
1928
self.assertEqual(result, 'TestTips.txt: Customer collaboration over contract negotiation\n')
2029

0 commit comments

Comments
 (0)