Skip to content

Commit

Permalink
Address warnings in test_simple_unit.py and lucene_grammar.py raised …
Browse files Browse the repository at this point in the history
…when running with Python 3.12.
  • Loading branch information
ptmcg committed Jun 18, 2023
1 parent e4f3ce2 commit d5aafc3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion examples/lucene_grammar.py
Expand Up @@ -311,7 +311,8 @@
a:b:c*
a:b:c~2.0
"""
z = """
# strings with backslashes still to be tested
z = r"""
\+blah
\-blah
foo \|| bar
Expand Down
10 changes: 5 additions & 5 deletions tests/test_simple_unit.py
Expand Up @@ -10,7 +10,7 @@
import unittest
import pyparsing as pp
from collections import namedtuple
from datetime import datetime
from datetime import datetime, timezone

ppt = pp.pyparsing_test
TestParseResultsAsserts = ppt.TestParseResultsAsserts
Expand Down Expand Up @@ -403,18 +403,18 @@ class TestParseAction(PyparsingExpressionTestCase):
PpTestSpec(
desc="Use two parse actions to convert numeric string, then convert to datetime",
expr=pp.Word(pp.nums).add_parse_action(
lambda t: int(t[0]), lambda t: datetime.utcfromtimestamp(t[0])
lambda t: int(t[0]), lambda t: datetime.fromtimestamp(t[0], timezone.utc)
),
text="1537415628",
expected_list=[datetime(2018, 9, 20, 3, 53, 48)],
expected_list=[datetime(2018, 9, 20, 3, 53, 48, tzinfo=timezone.utc)],
),
PpTestSpec(
desc="Use tokenMap for parse actions that operate on a single-length token",
expr=pp.Word(pp.nums).add_parse_action(
pp.token_map(int), pp.token_map(datetime.utcfromtimestamp)
pp.token_map(int), pp.token_map(lambda t: datetime.fromtimestamp(t, timezone.utc))
),
text="1537415628",
expected_list=[datetime(2018, 9, 20, 3, 53, 48)],
expected_list=[datetime(2018, 9, 20, 3, 53, 48, tzinfo=timezone.utc)],
),
PpTestSpec(
desc="Using a built-in function that takes a sequence of strs as a parse action",
Expand Down

0 comments on commit d5aafc3

Please sign in to comment.