Skip to content

Commit 8a8910d

Browse files
authored
Merge pull request #629 from ISISComputingGroup/Ticket8297_remove_six_usage
Remove usage of six
2 parents 7aa8bd1 + b0526bc commit 8a8910d

13 files changed

+19
-51
lines changed

common_tests/fermichopper.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from time import sleep
44

55
import itertools
6-
import six
76

87
from utils.channel_access import ChannelAccess
98
from utils.ioc_launcher import IOCRegister
@@ -26,8 +25,7 @@ class ErrorStrings(object):
2625
CONTROLLER_OVERSPEED = "Controller reports speed limit exceeded"
2726

2827

29-
@six.add_metaclass(ABCMeta)
30-
class FermichopperBase(object):
28+
class FermichopperBase(object, metaclass=ABCMeta):
3129
"""
3230
Tests for the Fermi Chopper IOC.
3331
"""

common_tests/instron_base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import abc
22
import math
33
import time
4-
import six
54

65
from utils.channel_access import ChannelAccess
76
from utils.ioc_launcher import IOCRegister
@@ -21,8 +20,7 @@
2120
CHANNELS = {"Position": 1, "Stress": 2, "Strain": 3}
2221

2322

24-
@six.add_metaclass(abc.ABCMeta)
25-
class InstronBase(object):
23+
class InstronBase(object, metaclass=abc.ABCMeta):
2624
"""
2725
Tests for the Instron IOC.
2826
"""

common_tests/jaws_manager_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
from utils.channel_access import ChannelAccess
22
from utils.ioc_launcher import IOCRegister
3-
import six
43
import abc
54

65
UNDERLYING_GAP_SP = "MOT:JAWS{}:{}GAP:SP"
76
UNDERLYING_CENT_SP = "MOT:JAWS{}:{}CENT:SP"
87
MOD_GAP = "JAWMAN:MOD:{}GAP:SP"
98

109

11-
@six.add_metaclass(abc.ABCMeta)
12-
class JawsManagerBase(object):
10+
class JawsManagerBase(object, metaclass=abc.ABCMeta):
1311
"""
1412
Base classes for all jaws manager tests.
1513
"""

common_tests/moxa12XX.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import six
21

32
from abc import ABCMeta, abstractmethod
43

@@ -7,8 +6,7 @@
76
from itertools import product
87

98

10-
@six.add_metaclass(ABCMeta)
11-
class Moxa12XXBase(object):
9+
class Moxa12XXBase(object, metaclass=ABCMeta):
1210
"""
1311
Tests for a moxa ioLogik e1240. (8x DC Voltage/Current measurements)
1412
"""

common_tests/riken_changeover.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import six
21
from abc import ABCMeta, abstractmethod
32
from utils.channel_access import ChannelAccess
43

@@ -8,8 +7,7 @@
87
from contextlib2 import ExitStack # PY2
98

109

11-
@six.add_metaclass(ABCMeta)
12-
class RikenChangeover(object):
10+
class RikenChangeover(object, metaclass=ABCMeta):
1311
"""
1412
Tests for a riken changeover.
1513

common_tests/tpgx6x.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import abc
22

3-
import six
4-
53
from utils.channel_access import ChannelAccess
64
from utils.testing import get_running_lewis_and_ioc
75

@@ -38,8 +36,7 @@ class ErrorStrings(object):
3836
IDENTIFICATION_ERROR = "Identification Error"
3937

4038

41-
@six.add_metaclass(abc.ABCMeta)
42-
class TpgBase(object):
39+
class TpgBase(object, metaclass=abc.ABCMeta):
4340

4441
@abc.abstractmethod
4542
def get_prefix(self):

common_tests/tti_common.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import abc
22

3-
import six
43
from parameterized import parameterized
54

65
from utils.testing import skip_if_recsim
76

87

9-
@six.add_metaclass(abc.ABCMeta)
10-
class TtiCommon(object):
8+
class TtiCommon(object, metaclass=abc.ABCMeta):
119

1210
@abc.abstractmethod
1311
def get_off_state_name(self):

run_tests.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from typing import List, Any
1111
import importlib
1212

13-
import six
1413
import xmlrunner
1514
import glob
1615

@@ -218,7 +217,7 @@ def prompt_user_to_run_tests(test_names, device_launchers):
218217
valid_answers = ["Y", "N"]
219218
print("Run tests? [{}]: {}".format('/'.join(valid_answers), test_names))
220219
while True:
221-
answer = six.moves.input().upper()
220+
answer = input().upper()
222221
if answer == "" or answer[0] not in valid_answers:
223222
print("Valid answers are: {}".format(" or ".join(valid_answers)))
224223
elif answer[0] == "N":
@@ -354,10 +353,6 @@ def run_tests(prefix, module_name, tests_to_run, device_launchers, failfast_swit
354353

355354

356355
if __name__ == '__main__':
357-
if six.PY2:
358-
print("IOC system tests should now be run under python 3. Aborting.")
359-
sys.exit(-1)
360-
361356
parser = argparse.ArgumentParser(
362357
description='Test an IOC under emulation by running tests against it')
363358
parser.add_argument('-l', '--list-devices',

tests/edwardstic.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import unittest
2-
import six
32

43
from abc import ABCMeta, abstractmethod
54

@@ -43,8 +42,7 @@ def get_common_channel_access():
4342
return ChannelAccess(device_prefix=DEVICE_PREFIX, default_timeout=15)
4443

4544

46-
@six.add_metaclass(ABCMeta)
47-
class EdwardsTICBase(object):
45+
class EdwardsTICBase(object, metaclass=ABCMeta):
4846
@abstractmethod
4947
def get_base_PV(self):
5048
"""
@@ -160,8 +158,7 @@ def test_GIVEN_device_disconnected_WHEN_base_PV_read_THEN_alert_and_priority_PVs
160158
# Assert alarms clear on reconnection
161159
self._check_alert_and_priority_PVs(ChannelAccess.Alarms.NONE)
162160

163-
@six.add_metaclass(ABCMeta)
164-
class GaugeTestBase(EdwardsTICBase):
161+
class GaugeTestBase(EdwardsTICBase, metaclass=ABCMeta):
165162

166163
@abstractmethod
167164
def get_gauge_number(self):

tests/zfcntrl.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import unittest
66
from time import sleep
77

8-
import six
9-
108
from parameterized import parameterized
119

1210
from utils.channel_access import ChannelAccess
@@ -457,15 +455,15 @@ def test_GIVEN_manual_mode_and_within_tolerance_WHEN_magnetometer_is_overloaded_
457455
def test_GIVEN_manual_mode_and_just_outside_tolerance_WHEN_magnetometer_is_overloaded_THEN_status_overloaded_and_setpoint_field_is_na(self):
458456
fields = {"X": 55, "Y": 66, "Z": 77}
459457
self._set_simulated_measured_fields(fields, overload=True)
460-
self._set_user_setpoints({k: v + 1.01 * STABILITY_TOLERANCE for k, v in six.iteritems(fields)})
458+
self._set_user_setpoints({k: v + 1.01 * STABILITY_TOLERANCE for k, v in fields.items()})
461459

462460
self._assert_at_setpoint(AtSetpointStatuses.NA)
463461
self._assert_status(Statuses.MAGNETOMETER_OVERLOAD)
464462

465463
def test_GIVEN_manual_mode_and_just_within_tolerance_WHEN_magnetometer_is_overloaded_THEN_status_overloaded_and_setpoint_field_is_na(self):
466464
fields = {"X": 55, "Y": 66, "Z": 77}
467465
self._set_simulated_measured_fields(fields, overload=True)
468-
self._set_user_setpoints({k: v + 0.99 * STABILITY_TOLERANCE for k, v in six.iteritems(fields)})
466+
self._set_user_setpoints({k: v + 0.99 * STABILITY_TOLERANCE for k, v in fields.items()})
469467

470468
self._assert_at_setpoint(AtSetpointStatuses.NA)
471469
self._assert_status(Statuses.MAGNETOMETER_OVERLOAD)
@@ -523,7 +521,7 @@ def test_WHEN_power_supplies_writes_fail_THEN_status_is_power_supply_writes_fail
523521
self._set_simulated_measured_fields(fields, overload=False)
524522

525523
# For this test we need changing fields so that we can detect that the writes failed
526-
self._set_user_setpoints({k: v + 10 * STABILITY_TOLERANCE for k, v in six.iteritems(fields)})
524+
self._set_user_setpoints({k: v + 10 * STABILITY_TOLERANCE for k, v in fields.items()})
527525
# ... and we also need large limits so that we see that the writes failed as opposed to a limits error
528526
self._set_output_limits(
529527
lower_limits={k: -999999 for k in FIELD_AXES},
@@ -609,7 +607,7 @@ def test_GIVEN_autofeedback_WHEN_measured_field_different_from_setpoints_THEN_po
609607
fields = {"X": 5, "Y": 0, "Z": -5}
610608

611609
adjustment_amount = 10 * STABILITY_TOLERANCE # To ensure that it is not considered stable to start with
612-
measured_fields = {k: measured_field_modifier(v, adjustment_amount) for k, v in six.iteritems(fields)}
610+
measured_fields = {k: measured_field_modifier(v, adjustment_amount) for k, v in fields.items()}
613611

614612
self._set_scaling_factors(scaling_factor, scaling_factor, scaling_factor, fiddle=1)
615613
self._set_simulated_measured_fields(measured_fields, overload=False)

utils/emulator_launcher.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from datetime import datetime
1313
from time import sleep, time
1414
from functools import partial
15-
import six
1615
from dataclasses import dataclass
1716
from typing import List, Any, Dict
1817

@@ -66,8 +65,7 @@ def remove_emulator(cls, name):
6665
del cls.RunningEmulators[name]
6766

6867

69-
@six.add_metaclass(abc.ABCMeta)
70-
class EmulatorLauncher(object):
68+
class EmulatorLauncher(object, metaclass=abc.ABCMeta):
7169

7270
def __init__(self, test_name, device, emulator_path, var_dir, port, options):
7371
"""

utils/ioc_launcher.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
from time import sleep
1111
from abc import ABCMeta
1212

13-
import six
14-
1513
from utils.channel_access import ChannelAccess
1614
from utils.free_ports import get_free_ports
1715
from utils.log_file import log_filename, LogFileManager
@@ -119,8 +117,7 @@ def add_ioc(cls, name, ioc):
119117
cls.RunningIOCs[name] = ioc
120118

121119

122-
@six.add_metaclass(ABCMeta)
123-
class BaseLauncher(object):
120+
class BaseLauncher(object, metaclass=ABCMeta):
124121
"""
125122
Launcher base, this is the base class for a launcher of application under test.
126123
"""

utils/testing.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import unittest
33
from time import sleep
44

5-
import six
6-
75
from utils.ioc_launcher import IOCRegister, IocLauncher
86
from utils.emulator_launcher import EmulatorRegister, LewisLauncher
97

@@ -141,7 +139,7 @@ class load time. This is necessary because otherwise the decorators don't proper
141139
reason (str): The reason for skipping the test
142140
"""
143141
def decorator(func):
144-
@six.wraps(func)
142+
@functools.wraps(func)
145143
def wrapper(*args, **kwargs):
146144
if condition():
147145
raise unittest.SkipTest(reason)
@@ -173,7 +171,7 @@ def add_method(method):
173171
method (func): The method to add to the class decorated. Should be callable.
174172
"""
175173

176-
@six.wraps(method)
174+
@functools.wraps(method)
177175
def wrapper(class_to_decorate):
178176
setattr(class_to_decorate, method.__name__, method)
179177
return class_to_decorate
@@ -218,7 +216,7 @@ def unstable_test(max_retries=2, error_class=AssertionError, wait_between_runs=0
218216
wait_between_runs: number of seconds to wait between each failed attempt at running the test
219217
"""
220218
def decorator(func):
221-
@six.wraps(func)
219+
@functools.wraps(func)
222220
def wrapper(self, *args, **kwargs):
223221
try:
224222
return func(self, *args, **kwargs) # Initial attempt to run the test "normally"

0 commit comments

Comments
 (0)