From 8cf1beb1839ce874730256aad7dfa4496d37c217 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sun, 15 Sep 2019 16:26:44 -0700 Subject: [PATCH] test_irc_parsers: fix Python 3.5 support open() only supports pathlib paths on 3.6 and later. --- test/parser-tests | 2 +- test/test_irc_parsers.py | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/test/parser-tests b/test/parser-tests index 1eea408..26c9dd8 160000 --- a/test/parser-tests +++ b/test/parser-tests @@ -1 +1 @@ -Subproject commit 1eea408666145cd4ef08f255523350ebef8f063f +Subproject commit 26c9dd841467b9746fb325e16292a0b7a93bc802 diff --git a/test/test_irc_parsers.py b/test/test_irc_parsers.py index c23c2d8..91df358 100644 --- a/test/test_irc_parsers.py +++ b/test/test_irc_parsers.py @@ -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):