Skip to content

Commit 8f4bf7a

Browse files
author
Bilal Al
committed
fixed if matching data is None
1 parent 220e5b1 commit 8f4bf7a

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
TESTS_REQUIRES = [
88
'flake8',
99
'pytest==7.0.1',
10-
'pytest-mock>=3.5.1',
10+
'pytest-mock==3.13.0',
1111
'coverage==6.2',
1212
'pytest-cov',
1313
'importlib-metadata==4.2',

splitio/models/grammar/matchers/semver.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,11 @@ def _match(self, key, attributes=None, context=None):
202202
if matching_data is None:
203203
return False
204204

205-
return self._semver.version == Semver(matching_data).version
205+
matcheing_semver = Semver.build(matching_data)
206+
if matcheing_semver is None:
207+
return False
208+
209+
return self._semver.version == matcheing_semver.version
206210

207211
def __str__(self):
208212
"""Return string Representation."""

tests/models/grammar/test_matchers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,10 +909,12 @@ def test_from_raw(self, mocker):
909909
def test_matcher_behaviour(self, mocker):
910910
"""Test if the matcher works properly."""
911911
parsed = matchers.from_raw(self.raw)
912-
assert parsed._match("2.1.8+rc")
912+
assert not parsed._match("2.1.8+rc")
913913
assert parsed._match("2.1.8")
914914
assert not parsed._match("2.1.5")
915915
assert not parsed._match("2.1.5-rc1")
916+
assert not parsed._match(None)
917+
assert not parsed._match("semver")
916918

917919
def test_to_json(self):
918920
"""Test that the object serializes to JSON properly."""

0 commit comments

Comments
 (0)