Code cleanup.

This commit is contained in:
Martin Mahner 2014-01-07 13:07:55 +01:00
parent ebdd36cfeb
commit d86f8b812b
4 changed files with 3 additions and 10 deletions

View file

@ -11,8 +11,7 @@
# #
# All configuration values have a default; values that are commented out # All configuration values have a default; values that are commented out
# serve to show the default. # serve to show the default.
#import sys
import sys
import os import os
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,

View file

@ -112,7 +112,7 @@ class NakedHtmlFormatter(HtmlFormatter):
def pygmentize(code_string, lexer_name=LEXER_DEFAULT): def pygmentize(code_string, lexer_name=LEXER_DEFAULT):
try: try:
lexer = lexer_name and get_lexer_by_name(lexer_name) \ lexer = lexer_name and get_lexer_by_name(lexer_name) \
or PythonLexer() or PythonLexer()
except Exception as e: except Exception:
lexer = PythonLexer() lexer = PythonLexer()
return highlight(code_string, lexer, NakedHtmlFormatter()) return highlight(code_string, lexer, NakedHtmlFormatter())

View file

@ -1,5 +1,4 @@
from datetime import datetime from datetime import datetime
from os import urandom
from random import SystemRandom from random import SystemRandom
from django.db import models from django.db import models

View file

@ -5,8 +5,6 @@ from django.test.client import Client
from django.test import TestCase from django.test import TestCase
from ..models import Snippet from ..models import Snippet
from ..forms import EXPIRE_DEFAULT
from ..highlight import LEXER_DEFAULT
class SnippetAPITestCase(TestCase): class SnippetAPITestCase(TestCase):
@ -121,8 +119,6 @@ class SnippetAPITestCase(TestCase):
} }
response = self.client.post(self.api_url, data) response = self.client.post(self.api_url, data)
content = response.content.decode('utf-8')
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertEqual(Snippet.objects.count(), 1) self.assertEqual(Snippet.objects.count(), 1)
@ -135,6 +131,5 @@ class SnippetAPITestCase(TestCase):
'lexer': 'foobar' 'lexer': 'foobar'
} }
response = self.client.post(self.api_url, data) response = self.client.post(self.api_url, data)
content = response.content.decode('utf-8')
self.assertEqual(response.status_code, 400) self.assertEqual(response.status_code, 400)
self.assertEqual(Snippet.objects.count(), 0) self.assertEqual(Snippet.objects.count(), 0)