Skip to content

Commit 991bc76

Browse files
authored
Fix regex warning; Skip inapplicable test; Add venv to Gitignore (#650)
* Add venv to .gitignore * Fix regex escape sequence warning in test_formats.py
1 parent 04a130e commit 991bc76

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,4 @@ docs/_build/
6868
docs/_autosummary/
6969
docs/_images/*.png
7070
docs/normal_data.csv
71+
venv/

tests/test_formats.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
from datascience import formats
55
import os
66
import time
7+
import pytest
78

89

910
def assert_equal(string1, string2):
1011
string1, string2 = str(string1), str(string2)
11-
whitespace = re.compile('\s')
12+
whitespace = re.compile(r'\s')
1213
purify = lambda s: whitespace.sub('', s)
1314
assert purify(string1) == purify(string2), "\n%s\n!=\n%s" % (string1, string2)
1415

@@ -92,11 +93,15 @@ def test_date_format():
9293
t.set_format('time', ds.DateFormatter("%Y-%m-%d %H:%M:%S.%f"))
9394
assert isinstance(t['time'][0], float)
9495

95-
96+
@pytest.mark.skipif(
97+
not hasattr(time, "tzset"),
98+
reason="time.tzset not available on this platform"
99+
)
96100
def test_date_formatter_format_value():
97101
formatter = formats.DateFormatter()
98102
os.environ["TZ"] = "UTC"
99-
time.tzset()
103+
if hasattr(time, "tzset"): # ✅ only call tzset if it exists
104+
time.tzset()
100105
assert_equal(formatter.format_value(1666264489.9004), "2022-10-20 11:14:49.900400")
101106

102107

0 commit comments

Comments
 (0)