3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +01:00

test_irc_parsers: fix Python 3.5 support

open() only supports pathlib paths on 3.6 and later.
This commit is contained in:
James Lu 2019-09-15 16:26:44 -07:00
parent 52001ac82d
commit 8cf1beb183
2 changed files with 13 additions and 5 deletions

@ -1 +1 @@
Subproject commit 1eea408666145cd4ef08f255523350ebef8f063f
Subproject commit 26c9dd841467b9746fb325e16292a0b7a93bc802

View File

@ -4,6 +4,7 @@ Runs IRC parser tests from ircdocs/parser-tests.
This test suite runs static code only.
"""
from pathlib import Path
import sys
import unittest
import yaml
@ -17,13 +18,20 @@ from pylinkirc.protocols.ircs2s_common import IRCCommonProtocol
class MessageParserTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
with open(PARSER_DATA_PATH / 'msg-split.yaml') as f:
if sys.version_info >= (3, 6):
_open = open
else:
def _open(f): # Coerse pathlib paths to str for py3.5 compat
return open(str(f))
with _open(PARSER_DATA_PATH / 'msg-split.yaml') as f:
cls.MESSAGE_SPLIT_TEST_DATA = yaml.safe_load(f)
with open(PARSER_DATA_PATH / 'userhost-split.yaml') as f:
with _open(PARSER_DATA_PATH / 'userhost-split.yaml') as f:
cls.USER_HOST_SPLIT_TEST_DATA = yaml.safe_load(f)
with open(PARSER_DATA_PATH / 'mask-match.yaml') as f:
with _open(PARSER_DATA_PATH / 'mask-match.yaml') as f:
cls.MASK_MATCH_TEST_DATA = yaml.safe_load(f)
with open(PARSER_DATA_PATH / 'validate-hostname.yaml') as f:
with _open(PARSER_DATA_PATH / 'validate-hostname.yaml') as f:
cls.VALIDATE_HOSTNAME_TEST_DATA = yaml.safe_load(f)
def testMessageSplit(self):