File: utils.py

package info (click to toggle)
gimp 3.0.4-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 210,076 kB
  • sloc: ansic: 842,287; lisp: 10,761; python: 10,318; cpp: 7,238; perl: 4,355; sh: 1,043; xml: 963; yacc: 609; lex: 348; javascript: 150; makefile: 43
file content (32 lines) | stat: -rwxr-xr-x 1,082 bytes parent folder | download | duplicates (2)
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

import inspect
import sys

gimp_test_filename = ''

def gimp_assert(subtest_name, test):
  '''
  Please call me like this, for instance, if I were testing if gimp_image_new()
  succeeded:
    gimp_assert("gimp_image_new()", image is not None)
  '''
  if not test:
    frames = inspect.getouterframes(inspect.currentframe())
    sys.stderr.write("\n**** START FAILED SUBTEST *****\n")
    sys.stderr.write("ERROR: {} - line {}: {}\n".format(gimp_test_filename,
                                                        frames[1].lineno,
                                                        subtest_name))
    sys.stderr.write("***** END FAILED SUBTEST ******\n\n")
  assert test

def gimp_c_assert(c_filename, error_msg, test):
  '''
  This is called by the platform only, and print out the GError message from the
  C test plug-in.
  '''
  if not test:
    sys.stderr.write("\n**** START FAILED SUBTEST *****\n")
    sys.stderr.write("ERROR: {}: {}\n".format(c_filename, error_msg))
    sys.stderr.write("***** END FAILED SUBTEST ******\n\n")
  assert test