tkrajina / gpxpy

gpx-py is a python GPX parser. GPX (GPS eXchange Format) is an XML based file format for GPS tracks.
Apache License 2.0
987 stars 223 forks source link

Remove call to deprecated assertEquals #241

Closed QuLogic closed 7 months ago

QuLogic commented 2 years ago

assertEquals was replaced by assertEqual, and the former has been deleted from Python 3.11.

hugovk commented 1 year ago

Update:

This was retained in Python 3.11 (released October 2022), but has already been removed in Python 3.12 (set for release October 2023):

Nevertheless, I recommend merging this fix. The old Python versions (3.6+) will still work with this fix.

Demo

$ python3.11 -m coverage run --source=gpxpy ./test.py
...
----------------------------------------------------------------------
Ran 137 tests in 2.115s

OK (skipped=1)
$ python3.12 -m coverage run --source=gpxpy ./test.py
...
======================================================================
ERROR: test_microsecond (__main__.GPXTests.test_microsecond)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/private/tmp/gpxpy/test.py", line 3448, in test_microsecond
    self.assertEquals(207343, gpx2.tracks[0].segments[0].points[0].time.microsecond) # type: ignore
    ^^^^^^^^^^^^^^^^^
AttributeError: 'GPXTests' object has no attribute 'assertEquals'. Did you mean: 'assertEqual'?

----------------------------------------------------------------------
Ran 137 tests in 1.373s

FAILED (errors=1, skipped=1)
havardAasen commented 7 months ago

@tkrajina Could this be included? Without this patch, the test-suite fails with Python 3.12, which is starting to roll out in distro's.

This function was deprecated in 3.2, so the substitution will work on all Python versions you support.