File: test_configuration.py

package info (click to toggle)
rednotebook 2.39%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 5,956 kB
  • sloc: python: 9,570; javascript: 4,103; xml: 128; sh: 58; makefile: 11
file content (34 lines) | stat: -rw-r--r-- 926 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import tempfile

from rednotebook import configuration


def test_io():
    with tempfile.NamedTemporaryFile(delete=False) as f:
        c1 = configuration.Config(f.name)
        c1["a"] = 1
        c1.write_list("b", ["foo", "bär"])
        c1.save_to_disk()
        c2 = configuration.Config(f.name)
        assert c1 == c2
        assert c2.read_list("b", []) == ["foo", "bär"]


def test_changed():
    with tempfile.NamedTemporaryFile(delete=False) as f:
        c = configuration.Config(f.name)
        assert not c.changed()
        c["a"] = 1
        assert c.changed()
        c.save_to_disk()
        assert not c.changed()
        c.read("a", "foo")
        assert not c.changed()
        c.read_list("a", "foo")
        assert not c.changed()
        c.read("b", "bar")
        assert c.changed()
        c.save_to_disk()
        assert not c.changed()
        c.read_list("c", "baz")
        assert c.changed()