Skip to content

Commit

Permalink
handling default=None
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlatwe committed Mar 4, 2021
1 parent 489807e commit c12a8b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/rez/rex_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ def commands():
elif isinstance(obj, VersionBinding):
range2 = VersionRange(str(obj))

# eg 'if intersects(ephemerals.get('foo.cli'), ...)'
elif obj is None:
range2 = VersionRange(obj)

else:
raise RuntimeError(
"Invalid type %s passed as first arg to 'intersects'" % type(obj)
Expand Down
8 changes: 8 additions & 0 deletions src/rez/tests/test_rex.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,10 @@ def test_intersects_ephemerals(self):
bar_on = intersects(ephemerals.get("foo.bar", "foo.bar-0"), "1")
self.assertFalse(bar_on) # workaround, see PR nerdvegas/rez#1030

ephemerals = EphemeralsBinding([])
bar_on = intersects(ephemerals.get("foo.bar", default=None), "0")
self.assertFalse(bar_on)

# ephemerals.get_range
ephemerals = EphemeralsBinding([Requirement(".foo.bar-1")])
bar_on = intersects(ephemerals.get_range("foo.bar", "0"), "1")
Expand All @@ -504,6 +508,10 @@ def test_intersects_ephemerals(self):
foo = intersects(ephemerals.get_range("foo", "==1.2.3"), "1.4")
self.assertTrue(foo)

ephemerals = EphemeralsBinding([])
bar_on = intersects(ephemerals.get_range("foo.bar", default=None), "0")
self.assertFalse(bar_on)


if __name__ == '__main__':
unittest.main()
Expand Down

0 comments on commit c12a8b9

Please sign in to comment.