Skip to content

Commit 0893a87

Browse files
erikwaolofk
authored andcommitted
Add test case for config write
1 parent b073ace commit 0893a87

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/test_config.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Licensed under the 2-Clause BSD License, see LICENSE for details.
33
# SPDX-License-Identifier: BSD-2-Clause
44

5+
import os
56
import os.path
67
import tempfile
78

@@ -84,3 +85,24 @@ def test_config_libraries():
8485
assert lib.location == os.path.join(library_root, "test_lib")
8586
assert lib.sync_uri == "https://github.com/fusesoc/fusesoc-cores"
8687
assert not lib.auto_sync
88+
89+
90+
def test_config_write():
91+
tcf = tempfile.NamedTemporaryFile(mode="w+", delete=False)
92+
tcf.write(
93+
EXAMPLE_CONFIG.format(
94+
build_root=build_root,
95+
cache_root=cache_root,
96+
cores_root=cores_root,
97+
library_root=library_root,
98+
)
99+
)
100+
tcf.flush()
101+
102+
with Config(tcf.name) as c:
103+
c.build_root = "/tmp"
104+
105+
conf = Config(tcf.name)
106+
107+
assert conf.build_root == "/tmp"
108+
os.remove(tcf.name)

0 commit comments

Comments
 (0)