summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgbrandl <devnull@localhost>2008-09-12 00:56:35 +0200
committergbrandl <devnull@localhost>2008-09-12 00:56:35 +0200
commit24978830445a819852bd5216dd78ed48c66a25c4 (patch)
tree96c975167b11e0cf5b499669e58f51f03f54c71e
parent4f99cd0913f07f5fafcd818dce59beaa25b7cfc1 (diff)
parent6dd9fa10fa4d2cd51e320a3b3722aa5269786d47 (diff)
downloadpygments-24978830445a819852bd5216dd78ed48c66a25c4.tar.gz
Merge with Ben.
-rw-r--r--pygments/token.py18
-rw-r--r--tests/test_token.py20
2 files changed, 11 insertions, 27 deletions
diff --git a/pygments/token.py b/pygments/token.py
index 6db41a56..4fc50919 100644
--- a/pygments/token.py
+++ b/pygments/token.py
@@ -201,21 +201,3 @@ STANDARD_TYPES = {
Generic.Subheading: 'gu',
Generic.Traceback: 'gt',
}
-
-
-
-if __name__ == '__main__':
- import sys
- # sanity check for token name dict: no duplicate entries!
- stp = STANDARD_TYPES.copy()
- stp[Token] = '---' # Token and Text do conflict, that is okay
- t = {}
- for k, v in stp.iteritems():
- t.setdefault(v, []).append(k)
- if len(t) == len(stp):
- print 'Okay!'
- sys.exit()
-
- for k, v in t.iteritems():
- if len(v) > 1:
- print "%r has more than one key: %r" % (k, v)
diff --git a/tests/test_token.py b/tests/test_token.py
index 8cf779f7..4c83b9ea 100644
--- a/tests/test_token.py
+++ b/tests/test_token.py
@@ -36,15 +36,17 @@ class TokenTest(unittest.TestCase):
self.assert_(token.string_to_tokentype('String') is token.String)
def test_sanity_check(self):
- try:
- try:
- old_stdout = sys.stdout
- sys.stdout = StringIO.StringIO()
- execfile(token.__file__.rstrip('c'), {'__name__': '__main__'})
- finally:
- sys.stdout = old_stdout
- except SystemExit:
- pass
+ stp = token.STANDARD_TYPES.copy()
+ stp[token.Token] = '---' # Token and Text do conflict, that is okay
+ t = {}
+ for k, v in stp.iteritems():
+ t.setdefault(v, []).append(k)
+ if len(t) == len(stp):
+ return # Okay
+
+ for k, v in t.iteritems():
+ if len(v) > 1:
+ self.fail("%r has more than one key: %r" % (k, v))
if __name__ == '__main__':