File: test_write_error.py

package info (click to toggle)
serd 0.32.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,816 kB
  • sloc: ansic: 7,229; python: 518; makefile: 5
file content (32 lines) | stat: -rwxr-xr-x 748 bytes parent folder | download
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
#!/usr/bin/env python3

# Copyright 2022-2025 David Robillard <d@drobilla.net>
# SPDX-License-Identifier: ISC

"""Test errors writing to a file."""

import sys
import shlex
import subprocess
import os

import serd_test_util as util

args = util.wrapper_args(__doc__, True)
command = shlex.split(args.wrapper) + [args.serdi, args.input]

if os.path.exists("/dev/full"):
    with open("/dev/full", "w", encoding="utf-8") as out:
        proc = subprocess.run(
            command,
            encoding="utf-8",
            check=False,
            stdout=out,
            stderr=subprocess.PIPE,
        )

    assert proc.returncode != 0
    assert "error" in proc.stderr

else:
    sys.stderr.write("warning: /dev/full not present, skipping test")