mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-09-09 11:47:14 +02:00
safe_join: raise ValueError on None parameters and update tests
Changed safe_join to raise ValueError if base or tail is None instead of returning 'None/path'. Adjusted unit tests accordingly to expect exceptions for None inputs and kept empty-string handling valid. Ref: https://chatgpt.com/share/68b55850-e854-800f-9702-09ea956b8dc4
This commit is contained in:
@@ -24,10 +24,15 @@ class TestSafeJoinFilter(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_base_none(self):
|
||||
self.assertEqual(safe_join(None, 'path'), '')
|
||||
with self.assertRaises(ValueError):
|
||||
safe_join(None, 'path')
|
||||
|
||||
def test_tail_none(self):
|
||||
with self.assertRaises(ValueError):
|
||||
safe_join('http://example.com', None)
|
||||
|
||||
def test_base_empty(self):
|
||||
self.assertEqual(safe_join('', 'path'), '')
|
||||
self.assertEqual(safe_join('', 'path'), '/path')
|
||||
|
||||
def test_tail_empty(self):
|
||||
# joining with empty tail should yield base with trailing slash
|
||||
|
Reference in New Issue
Block a user