Skip to content

Commit

Permalink
test: assert that get_timestamp() is not None
Browse files Browse the repository at this point in the history
mypy complains:

```
tests/unit/test_problem_report.py:79: error: Value of type variable "_S" of "assertAlmostEqual" of "TestCase" cannot be "float | int | None"  [type-var]
tests/unit/test_problem_report.py:84: error: Value of type variable "_S" of "assertAlmostEqual" of "TestCase" cannot be "int | None"  [type-var]
```
  • Loading branch information
bdrung authored and schopin-pro committed Jun 21, 2024
1 parent 4525247 commit 2f18763
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/unit/test_problem_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,19 @@ def test_ctor_arguments(self):
pr = problem_report.ProblemReport(date="19801224 12:34")
self.assertEqual(pr["Date"], "19801224 12:34")

def test_get_timestamp(self):
def test_get_timestamp(self) -> None:
"""get_timestamp() returns timestamp."""
r = problem_report.ProblemReport()
self.assertAlmostEqual(r.get_timestamp(), time.time(), delta=2)
timestamp = r.get_timestamp()
assert timestamp
self.assertAlmostEqual(timestamp, time.time(), delta=2)

r["Date"] = "Thu Jan 9 12:00:00 2014"
# delta is ±12 hours, as this depends on the timezone that the test is
# run in
self.assertAlmostEqual(r.get_timestamp(), 1389265200, delta=43200)
timestamp = r.get_timestamp()
assert timestamp
self.assertAlmostEqual(timestamp, 1389265200, delta=43200)

def test_get_timestamp_locale_german(self):
"""get_timestamp() returns date when LC_TIME is set."""
Expand Down

0 comments on commit 2f18763

Please sign in to comment.