Beispiel #1
0
    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)
Beispiel #2
0
    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)
Beispiel #3
0
    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)
Beispiel #4
0
    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)
Beispiel #5
0
    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
Beispiel #6
0
 def test_skipbase(self):
     assert unoccupied('foo', [], skipbase=True) == 'foo-1'
Beispiel #7
0
 def test_occupied_is_str(self):
     with pytest.raises(TypeError):
         unoccupied('foo', 'bar')  # str as `occupied` are not allow
Beispiel #8
0
 def test_basic(self, basename, occupied, expected):
     assert unoccupied(basename, occupied) == expected