Skip to content

Commit c6a6116

Browse files
committed
Use robot.utils.platform constants where applicable
1 parent 2f6c16b commit c6a6116

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

src/robot/libraries/OperatingSystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,7 @@ def close(self):
14281428
# In Jython return code can be between '-255' - '255'
14291429
# In Python return code must be converted with 'rc >> 8' and it is
14301430
# between 0-255 after conversion
1431-
if os.sep == '\\' or sys.platform.startswith('java'):
1431+
if WINDOWS or JYTHON:
14321432
return rc % 256
14331433
return rc >> 8
14341434

src/robot/running/signalhandler.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
import sys
1717
from threading import currentThread
1818
import signal
19-
if sys.platform.startswith('java'):
20-
from java.lang import IllegalArgumentException
21-
else:
22-
IllegalArgumentException = ValueError
2319

2420
from robot.errors import ExecutionFailed
2521
from robot.output import LOGGER
22+
from robot.utils import JYTHON
23+
24+
if JYTHON:
25+
from java.lang import IllegalArgumentException
26+
else:
27+
IllegalArgumentException = ValueError
2628

2729

2830
class _StopSignalMonitor(object):
@@ -40,7 +42,7 @@ def __call__(self, signum, frame):
4042
sys.__stderr__.write('Execution forcefully stopped.\n')
4143
raise SystemExit()
4244
sys.__stderr__.write('Second signal will force exit.\n')
43-
if self._running_keyword and not sys.platform.startswith('java'):
45+
if self._running_keyword and not JYTHON:
4446
self._stop_execution_gracefully()
4547

4648
def _stop_execution_gracefully(self):

src/robot/utils/compress.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,16 @@
1414
# limitations under the License.
1515

1616
import base64
17-
import sys
1817

19-
from .platform import PY2
18+
from .platform import JYTHON, PY2
2019

2120

2221
def compress_text(text):
2322
result = base64.b64encode(_compress(text.encode('UTF-8')))
2423
return result if PY2 else result.decode('ASCII')
2524

2625

27-
if not sys.platform.startswith('java'):
26+
if not JYTHON:
2827

2928
import zlib
3029

utest/utils/test_compat.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
import unittest
44

5-
from robot.utils import isatty, PYTHON
5+
from robot.utils import isatty
66
from robot.utils.asserts import assert_equal, assert_false, assert_raises
77

88

@@ -23,8 +23,7 @@ def test_with_detached_io_buffer(self):
2323
with io.StringIO() as stream:
2424
wrapper = io.TextIOWrapper(stream, 'UTF-8')
2525
wrapper.detach()
26-
exc_type = ValueError if PYTHON else AttributeError
27-
assert_raises(exc_type, wrapper.isatty)
26+
assert_raises((ValueError, AttributeError), wrapper.isatty)
2827
assert_false(isatty(wrapper))
2928

3029

0 commit comments

Comments
 (0)