@@ -0,0 +1,2756 @@
+#!/usr/bin/env python%0A%0A################################################################################%0A'''%0ACopyright (c) 2013, janague %3Cjanague@gmail.com%3E%0AAll rights reserved.%0A%0ARedistribution and use in source and binary forms, with or without%0Amodification, are permitted provided that the following conditions are met: %0A%0A1. Redistributions of source code must retain the above copyright notice, this%0A   list of conditions and the following disclaimer. %0A2. Redistributions in binary form must reproduce the above copyright notice,%0A   this list of conditions and the following disclaimer in the documentation%0A   and/or other materials provided with the distribution. %0A%0ATHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS %22AS IS%22 AND%0AANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED%0AWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE%0ADISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR%0AANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES%0A(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;%0ALOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND%0AON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT%0A(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS%0ASOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.%0A'''%0A################################################################################%0A%0Aimport unittest%0A%0Aimport sys%0Afrom StringIO import StringIO%0A%0Aimport pywebspider%0A%0ALENGTH_LEVEL1 = 407  # Length of output for first level (now)%0ALENGTH_LEVEL2 = 14004  # Length of output for second level (now)%0ALENGTH_LEVEL3 = 456575  # Length of output for third level (now)%0A%0Aclass TestWebSpider (unittest.TestCase):%0A    def setUp(self):%0A        self.held, sys.stdout = sys.stdout, StringIO()%0A        %0A    # Test number of links in level 1%0A    def test_first_level (self):%0A        url = %22http://herraiz.org%22%0A        depth = 1%0A        pywebspider.print_links(url, depth)%0A        output = len(sys.stdout.getvalue())%0A        self.assertEqual(output, LENGTH_LEVEL1)%0A%0A    # Test number of links in level 2%0A    def test_second_level (self):%0A        url = %22http://herraiz.org%22%0A        depth = 2%0A        pywebspider.print_links(url, depth)%0A        output = len(sys.stdout.getvalue())%0A        self.assertEqual(output, LENGTH_LEVEL2)%0A        %0A        %0A    # Test number of links in level 3%0A    def test_third_level (self):%0A        url = %22http://herraiz.org%22%0A        depth = 3%0A        pywebspider.print_links(url, depth)%0A        output = len(sys.stdout.getvalue())%0A        self.assertEqual(output, LENGTH_LEVEL3)%0A%0Aif __name__ == '__main__':%0A    unittest.main()%0A

Fix #5: Unit test