Skip to content

Commit 4ae032d

Browse files
removed global (#48)
* removed global * docstring added
1 parent 0b1c356 commit 4ae032d

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

tests/testBaseStateMachine.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@
33
import unittest
44
sys.path.append('../src')
55

6-
test = 2
6+
test = [2]
7+
8+
9+
def setTest(value):
10+
"""Set the test variable to the value specified"""
11+
test[0] = value
12+
13+
14+
def getTest():
15+
"""Return the value of test variable"""
16+
return test[0]
717

818

919
def everFalse():
@@ -23,15 +33,14 @@ def testPrint():
2333

2434
def setTestTo3():
2535
"""Sets Test to 3"""
26-
global test # Needed to modify global copy of globvar
27-
print(test)
28-
test = 3
29-
print(test)
36+
print(getTest())
37+
setTest(3)
38+
print(getTest())
3039

3140

3241
def printTest():
3342
"""Print Test"""
34-
print("Test: ", test)
43+
print("Test: ", getTest())
3544

3645

3746
class TestBaseStateMachine(unittest.TestCase):
@@ -164,8 +173,7 @@ def test5(self):
164173

165174
def test6(self):
166175
"""Test 6 for state machine"""
167-
global test
168-
test = 2
176+
setTest(2)
169177
sm = StateMachine("../sample/sample6.xml")
170178

171179
sm.LoadStateMachine()

0 commit comments

Comments
 (0)