Skip to content

Commit 81fa829

Browse files
committed
[File] raise DuplicateName as in all other create methods
1 parent 8bfbb4c commit 81fa829

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

nixio/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def create_block(self, name="", type_="", compression=Compression.Auto,
419419
return self.blocks[entity_id]
420420

421421
if name in self._data:
422-
raise ValueError("Block with the given name already exists!")
422+
raise DuplicateName("Block with the given name already exists!")
423423
if compression == Compression.Auto:
424424
compression = self._compr
425425
block = Block.create_new(self, self._data, name, type_, compression)

nixio/test/test_file.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import time
1414

1515
import nixio as nix
16+
from nixio.exceptions.exceptions import DuplicateName
1617
import nixio.file as filepy
1718
from nixio.exceptions import InvalidFile
1819
from .tmp import TempDir
@@ -47,7 +48,8 @@ def test_file_blocks(self):
4748
assert len(self.file.blocks) == 0
4849

4950
block = self.file.create_block("test block", "recordingsession")
50-
51+
with self.assertRaises(DuplicateName):
52+
self.file.create_block("test block", "recordingsession")
5153
assert len(self.file.blocks) == 1
5254

5355
assert block in self.file.blocks

0 commit comments

Comments
 (0)