From f80a295b856abf7e8f3cfb888dd320575e430c3a Mon Sep 17 00:00:00 2001 From: Chris Mackey Date: Mon, 11 Mar 2019 15:25:35 -0400 Subject: [PATCH] fix(location): Fixing Location.duplicate() method --- ladybug/location.py | 5 +++-- tests/location_test.py | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ladybug/location.py b/ladybug/location.py index 2362f400..69ed15a5 100644 --- a/ladybug/location.py +++ b/ladybug/location.py @@ -157,8 +157,9 @@ def meridian(self): def duplicate(self): """Duplicate location.""" - return self(self.city, self.country, self.latitude, self.longitude, - self.time_zone, self.elevation, self.station_id, self.source) + return Location(self.city, self.state, self.country, + self.latitude, self.longitude, self.time_zone, self.elevation, + self.station_id, self.source) @property def ep_style_location_string(self): diff --git a/tests/location_test.py b/tests/location_test.py index 47a9f1c9..3b46cc7a 100644 --- a/tests/location_test.py +++ b/tests/location_test.py @@ -121,6 +121,27 @@ def test_json_methods(self): assert loc_from_json.elevation == elevation assert loc_from_json.country == country + def test_duplicate(self): + """Test the duplicate method.""" + city = 'Tehran' + country = 'Iran' + latitude = 36 + longitude = 34 + time_zone = 3.5 + elevation = 54 + + loc = Location(city=city, country=country, latitude=latitude, + longitude=longitude, time_zone=time_zone, + elevation=elevation) + loc_dup = loc.duplicate() + + assert loc.city == loc_dup.city == city + assert loc.country == loc_dup.country == country + assert loc.latitude == loc_dup.latitude == latitude + assert loc.longitude == loc_dup.longitude == longitude + assert loc.time_zone == loc_dup.time_zone == time_zone + assert loc.elevation == loc_dup.elevation == elevation + if __name__ == "__main__": unittest.main()