def test_name_finder_return_elem_not_str_or_none(self): with pytest.raises(TypeError): def pseudo_name_finder(basename, norm_occupied): return ['return a list'] unoccupied('foo', ['foo', 'bar'], pseudo_name_finder)
def test_name_finder_return_basename(self): with pytest.raises(UnoccupiedNameNotFound): def pseudo_name_finder(basename, norm_occupied): return basename unoccupied('foo', ['foo'], pseudo_name_finder)
def test_name_finder_return_elem_in_occupied(self): with pytest.raises(UnoccupiedNameNotFound): def pseudo_name_finder(basename, norm_occupied): return 'bar' unoccupied('foo', ['foo', 'bar'], pseudo_name_finder)
def test_occupied_become_frozenset(self): def pseudo_name_finder(basename, norm_occupied): assert isinstance(norm_occupied, frozenset) return 'whatever' unoccupied('foo', ['foo'], pseudo_name_finder)
def test_call_name_finder_only_needed(self): called = False def pseudo_name_finder(basename, norm_occupied): nonlocal called called = True return 'whatever' unoccupied('foo', [], pseudo_name_finder) assert called is False unoccupied('foo', ['foo'], pseudo_name_finder) assert called is True
def test_skipbase(self): assert unoccupied('foo', [], skipbase=True) == 'foo-1'
def test_occupied_is_str(self): with pytest.raises(TypeError): unoccupied('foo', 'bar') # str as `occupied` are not allow
def test_basic(self, basename, occupied, expected): assert unoccupied(basename, occupied) == expected