from unittest import TestCase, main
from derpibooru import Search

class Test_Search_Live(TestCase):
  def test_query(self):
    """
    Test a query and make sure it returns correct image count and all images
    are valid
    """
    limit, tag = 10, "sunset shimmer"
    images = [image for image in Search().query(tag).limit(limit)]

    self.assertEqual(len(images), limit)
    
    for image in images:
      self.assertIsNotNone(image)
      self.assertTrue(tag in image.tags)

  def test_ascending(self):
    """
    Tests the functionality of ascending search
    """
    limit = 10
    images = [image for image in Search().ascending().limit(limit)]

    self.assertEqual(len(images), limit)

    for image in images:
      self.assertIsNotNone(image)
      """
      Must return images with IDs from 0 to 10
      """
      self.assertLessEqual(image.id_number, 10)

      """
      Check if the images are in sequential order
      by comparing the ID of the next image
      """
      if image is not images[-1]:
        next_image = images[images.index(image) + 1]
        self.assertLess(image.id_number, next_image.id_number)

  def test_descending(self):
    """
    Tests the functionality of descending search
    """
    limit = 10
    images = [image for image in Search().descending().limit(limit)]

    self.assertEqual(len(images), limit)

    for image in images:
      self.assertIsNotNone(image)
      """
      Check if the images are in sequential order
      by comparing the ID of the next image
      """
      if image is not images[-1]:
        next_image = images[images.index(image) + 1]
        self.assertGreater(image.id_number, next_image.id_number)

if __name__ == "__main__":
  main()

@@ -2,106 +2,34 @@
 rom 
-unittest import TestCase, main%0Afrom derpibooru import Search%0A%0Aclass Test_Search_Live(TestCase):%0A  
+derpibooru import Search%0A%0A
 def 
@@ -43,124 +43,108 @@
 ery(
-self
 ):%0A
-  
   %22%22%22%0A
-  
   Test
- a query and make sure it returns correct image
+s whether the results in a query
  co
-u
 nt
- and all images%0A    are valid%0A  
+ain the tag that was being searched%0A  for%0A
   %22%22%22%0A
-  
   li
@@ -175,18 +175,16 @@
 himmer%22%0A
-  
   images
@@ -243,35 +243,23 @@
 it)%5D%0A%0A  
-  self.assertEqual(
+assert 
 len(imag
@@ -265,24 +265,19 @@
 ges)
-,
+ ==
  limit
-)%0A    %0A  
+%0A%0A
   fo
@@ -303,60 +303,15 @@
     
-  
-self.
 assert
-IsNotNone(image)%0A      self.assertTrue(
+ 
 tag 
@@ -323,21 +323,18 @@
 age.tags
-)
 %0A%0A
-  
 def test
@@ -344,33 +344,27 @@
 cending(
-self
 ):%0A
-  
   %22%22%22%0A  
   Tests 
@@ -359,64 +359,69 @@
 %22%0A  
- 
- 
 Tests 
-the functionality of ascending search%0A  
+whether ascending search is in the correct order%0A
   %22%22%22%0A
-  
   li
@@ -421,34 +421,32 @@
 %22%22%0A  limit = 10%0A
-  
   images = %5Bimag
@@ -498,35 +498,23 @@
 it)%5D%0A%0A  
-  self.assertEqual(
+assert 
 len(imag
@@ -512,36 +512,35 @@
  len(images)
-,
+ ==
  limit
-)
 %0A%0A
-  
   for image 
@@ -558,169 +558,9 @@
     
-  self.assertIsNotNone(image)%0A      %22%22%22%0A      Must return images with IDs from 0 to 10%0A      %22%22%22%0A      self.assertLessEqual(image.id_number, 10)%0A%0A      %22%22%22%0A     
+#
  Che
@@ -579,34 +579,33 @@
 ages are in 
-sequential
+ascending
  order%0A     
@@ -595,33 +595,33 @@
 nding order%0A    
- 
+#
  by comparing th
@@ -638,37 +638,26 @@
 e next image
-%0A      %22%22%22%0A 
  
+%0A
     if image
@@ -668,34 +668,32 @@
 not images%5B-1%5D:%0A
-  
       next_image
@@ -737,26 +737,15 @@
     
-  self.
 assert
-Less(
+ 
 imag
@@ -747,33 +747,34 @@
  image.id_number
-,
+ %3C
  next_image.id_n
@@ -778,21 +778,18 @@
 d_number
-)
 %0A%0A
-  
 def test
@@ -804,33 +804,25 @@
 ing(
-self
 ):%0A  
- 
- 
 %22%22%22%0A
-  
   Tests 
 the 
@@ -821,57 +821,64 @@
 sts 
-the functionality of descending search%0A  
+whether descending search is in the correct order%0A
   %22%22%22%0A
-  
   li
@@ -886,18 +886,16 @@
 it = 10%0A
-  
   images
@@ -960,27 +960,15 @@
 %0A%0A  
- 
- self.assertEqual(
+assert 
 len(
@@ -978,20 +978,19 @@
 ges)
-,
+ ==
  limit
-)
 %0A%0A
-  
   fo
@@ -1014,55 +1014,9 @@
 :%0A  
-    self.assertIsNotNone(image)%0A      %22%22%22%0A     
+#
  Che
@@ -1034,27 +1034,37 @@
 mage
+ ID
 s are 
-in sequential
+listed in descending
  ord
@@ -1068,19 +1068,17 @@
 order%0A  
-   
+#
  by comp
@@ -1112,20 +1112,8 @@
 age%0A
-      %22%22%22%0A  
     
@@ -1136,26 +1136,24 @@
 images%5B-1%5D:%0A
-  
       next_i
@@ -1201,29 +1201,15 @@
     
-  self.assertGreater(
+assert 
 imag
@@ -1219,17 +1219,18 @@
 d_number
-,
+ %3E
  next_im
@@ -1246,43 +1246,6 @@
 mber
-)%0A%0Aif __name__ == %22__main__%22:%0A  main()
+%0A
 %0A

Migrate unit tests from unittest to py.test for easier and more flexible testing