Skip to content

Commit

Permalink
changes from 2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarbaugh committed Apr 29, 2020
1 parent 412957c commit 442364c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ Changelog
* added type annotations


2.0.2
~~~~~

* restore DC in lookup() and mapping()


2.0.1
~~~~~

Expand Down
2 changes: 1 addition & 1 deletion us/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def lookup(val, field: Optional[str] = None, use_cache: bool = True) -> Optional
if use_cache and cache_key in _lookup_cache:
matched_state = _lookup_cache[cache_key]

for state in itertools.chain(STATES_AND_TERRITORIES, OBSOLETE):
for state in STATES_AND_TERRITORIES:
if val == getattr(state, field):
matched_state = state
if use_cache:
Expand Down
9 changes: 8 additions & 1 deletion us/tests/test_us.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def test_name_lookup():

def test_obsolete_lookup():
for state in us.OBSOLETE:
assert us.states.lookup(state.name) == state
assert us.states.lookup(state.name) is None


# test metaphone
Expand Down Expand Up @@ -117,6 +117,13 @@ def test_wayoming():
assert us.states.lookup("Wayoming") is None


def test_dc():
assert us.states.DC not in us.STATES
assert us.states.lookup("DC") == us.states.DC
assert us.states.lookup("District of Columbia") == us.states.DC
assert "DC" in us.states.mapping("abbr", "name")


# shapefiles


Expand Down

0 comments on commit 442364c

Please sign in to comment.