Skip to content

Commit

Permalink
Synchronize test with corresponding test in Brian
Browse files Browse the repository at this point in the history
  • Loading branch information
mstimberg committed Jan 10, 2025
1 parent 424495b commit ac051a1
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions brian2cuda/tests/test_cuda_standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,21 +326,39 @@ def test_delete_code_data():
@pytest.mark.cuda_standalone
@pytest.mark.standalone_only
def test_delete_directory():
set_device('cuda_standalone', build_on_run=True, directory=None)
group = NeuronGroup(10, 'dv/dt = -v / (10*ms) : volt', method='exact')
group.v = np.arange(10)*mV # uses the static array mechanism
set_device("cuda_standalone", build_on_run=True, directory=None)
group = NeuronGroup(10, "dv/dt = -v / (10*ms) : volt", method="exact")
group.v = np.arange(10) * mV # uses the static array mechanism
run(defaultclock.dt)
# Add a new file
dummy_file = os.path.join(device.project_dir, 'results', 'dummy.txt')
open(dummy_file, 'w').flush()
dummy_file = os.path.join(device.project_dir, "results", "dummy.txt")
open(dummy_file, "w").flush()
assert os.path.isfile(dummy_file)
with catch_logs() as logs:
device.delete(directory=True)
assert len(logs) == 1
assert (
len(
[
l
for l in logs
if l[1] == "brian2.devices.cpp_standalone.device.delete_skips_directory"
]
)
== 1
)
assert os.path.isfile(dummy_file)
with catch_logs() as logs:
device.delete(directory=True, force=True)
assert len(logs) == 0
assert (
len(
[
l
for l in logs
if l[1] == "brian2.devices.cpp_standalone.device.delete_skips_directory"
]
)
== 0
)
# everything should be deleted
assert not os.path.exists(device.project_dir)

Expand Down

0 comments on commit ac051a1

Please sign in to comment.