File: test101.py

package info (click to toggle)
pychecker 0.8.19-10
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,484 kB
  • ctags: 2,114
  • sloc: python: 9,968; sh: 98; makefile: 13
file content (33 lines) | stat: -rw-r--r-- 526 bytes parent folder | download | duplicates (5)
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
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4

# see https://sourceforge.net/tracker/index.php?func=detail&aid=1563495&group_id=24686&atid=382217

'd'

__pychecker__ = 'blacklist=wrongname'

import os
import imp
import tempfile

code = """
class C:
    pass

c = C()
"""

# create a temporary file for the module
(fd, path) = tempfile.mkstemp()
os.write(fd, code)
os.close(fd)

temp = imp.load_source('temp', path)

# change class's module to trigger the error
temp.C.__module__ = 'wrongname'

# clean up
os.unlink(path)