Skip to content

Commit

Permalink
Fix #157: Sense.word() object uses same Wordnet
Browse files Browse the repository at this point in the history
  • Loading branch information
goodmami committed Sep 22, 2022
1 parent ea450b2 commit a1b7bdc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
* `wn.download()` no longer uses Python features unavailable in 3.7
when recovering from download errors
* `Sense.synset()` now creates a `Synset` properly linked to the same
`Wordnet` object ([#168])
`Wordnet` object ([#157], [#168])
* `Sense.word()` now creates a `Word` properly linked to the same
`Wordnet` object ([#157])


## [v0.9.1]
Expand Down Expand Up @@ -585,4 +587,5 @@ abandoned, but this is an entirely new codebase.
[#154]: https://github.com/goodmami/wn/issues/154
[#155]: https://github.com/goodmami/wn/issues/155
[#156]: https://github.com/goodmami/wn/issues/156
[#157]: https://github.com/goodmami/wn/issues/157
[#168]: https://github.com/goodmami/wn/issues/168
10 changes: 10 additions & 0 deletions tests/secondary_query_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ def test_sense_synset():
== wn.synset('test-es-0001-n'))


@pytest.mark.usefixtures('mini_db')
def test_sense_issue_157():
# https://github.com/goodmami/wn/issues/157
sense = wn.sense('test-en-information-n-0001-01')
# This test uses non-public members, which is not ideal, but there
# is currently no better alternative.
assert sense._wordnet is sense.word()._wordnet
assert sense._wordnet is sense.synset()._wordnet


@pytest.mark.usefixtures('mini_db')
def test_sense_examples():
assert wn.sense('test-en-information-n-0001-01').examples() == []
Expand Down
2 changes: 1 addition & 1 deletion wn/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ def word(self) -> Word:
Word('pwn-spigot-n')
"""
return word(id=self._entry_id)
return self._wordnet.word(id=self._entry_id)

def synset(self) -> Synset:
"""Return the synset of the sense.
Expand Down

0 comments on commit a1b7bdc

Please sign in to comment.