]> gitweb.fperrin.net Git - djsite.git/commitdiff
Add a pyflakes check, and fix the warnings
authorFrédéric Perrin <fred@fperrin.net>
Sun, 9 Oct 2016 23:21:48 +0000 (00:21 +0100)
committerFrédéric Perrin <fred@fperrin.net>
Sun, 9 Oct 2016 23:21:48 +0000 (00:21 +0100)
quotes/test_pyflakes.py [new file with mode: 0644]
quotes/tests.py
quotes/views.py

diff --git a/quotes/test_pyflakes.py b/quotes/test_pyflakes.py
new file mode 100644 (file)
index 0000000..535c13a
--- /dev/null
@@ -0,0 +1,22 @@
+from django.test import TestCase
+
+import pyflakes.api
+import os
+
+class PyflakesTest(TestCase):
+    def setUp(self):
+        topdir = os.path.dirname(os.path.realpath(__file__))
+        self.pythonfiles = []
+
+        for folder, subfolders, files in os.walk(topdir):
+            if 'migrations' in subfolders:
+                subfolders.remove('migrations')
+
+            for file in files:
+                if not file.endswith('.py'):
+                    continue
+                self.pythonfiles += [os.path.join(folder, file)]
+    
+    def test_pyflakes(self):
+        for file in self.pythonfiles:
+            self.assertEqual(pyflakes.api.checkPath(file), 0)
index fe7e0a80456ac99edd9adbe959ecb4dce352e7a5..66ff00b946b8500a034412e020f80b85fce940ad 100644 (file)
@@ -9,11 +9,13 @@ class QuoteTest(TestCase):
         a1 = Author.objects.create(name="JFK")
         w1 = Work.objects.create(name="Berlin speech", author=a1)
         q1 = Quote.objects.create(text="Ich bin...", work=w1)
         a1 = Author.objects.create(name="JFK")
         w1 = Work.objects.create(name="Berlin speech", author=a1)
         q1 = Quote.objects.create(text="Ich bin...", work=w1)
+        self.q1 = q1
 
     def test_one(self):
         q = Quote.objects.filter(text__startswith="Ich")
         self.assertEqual(q.count(), 1)
         q = q[0]
 
     def test_one(self):
         q = Quote.objects.filter(text__startswith="Ich")
         self.assertEqual(q.count(), 1)
         q = q[0]
+        self.assertEqual(q, self.q1)
         self.assertEqual(q.work.author.name, "JFK")
 
 class ViewsTest(TestCase):
         self.assertEqual(q.work.author.name, "JFK")
 
 class ViewsTest(TestCase):
index bd7f6f605bb142cd44ad196368fa252162dd421c..df4081d5b79b251ff5523b98d283dd470b2367d2 100644 (file)
@@ -1,6 +1,4 @@
 from django.shortcuts import render
 from django.shortcuts import render
-from django.http import HttpResponse
-from django.template import loader
 
 from random import randint
 
 
 from random import randint