示例#1
0
 def test_pypi_user(self, user_packages):
     user_packages.side_effect = lambda u: ['p1']
     sys.argv = ['pep438', '-u', 'testuser']
     with patch_io() as new:
         main()
         user_packages.assert_called_once_with('testuser')
         self.valid_package.assert_called_once_with('p1')
         self.get_urls.called_once_with('p1')
         self.assertEqual(new.stdout.getvalue(), "\u2713 p1: 0 URLs\n")
示例#2
0
 def test_valid_package(self, valid_package, get_links):
     valid_package.new_callable = lambda p: True
     get_links.new_callable = []
     sys.argv = ['pep438', 'p1', 'p2']
     with patch_io() as new:
         main()
         self.assertEqual(new.stderr.getvalue(), "")
         self.assertEqual(new.stdout.getvalue(),
                          "\u2717 p1: 0 links\n\u2717 p2: 0 links\n")
示例#3
0
 def test_errors_only(self):
     sys.argv = ['pep438', '--errors-only', 'p1', 'p2']
     self.get_urls.side_effect = lambda p: ['1', '2'] if p == 'p1' else []
     with patch_io() as new:
         main()
         self.assertEqual(self.valid_package.call_count, 2)
         self.assertEqual(self.get_urls.call_count, 2)
         self.assertEqual(new.stderr.getvalue(), "")
         self.assertEqual(new.stdout.getvalue(), "\u2717 p1: 2 URLs\n")
示例#4
0
 def test_valid_package(self):
     sys.argv = ['pep438', 'p1', 'p2']
     with patch_io() as new:
         main()
         self.assertEqual(self.valid_package.call_count, 2)
         self.assertEqual(self.get_urls.call_count, 2)
         self.assertEqual(new.stderr.getvalue(), "")
         self.assertEqual(new.stdout.getvalue(),
                          "\u2713 p1: 0 URLs\n\u2713 p2: 0 URLs\n")
示例#5
0
 def test_valid_package(self, valid_package, get_links):
     valid_package.new_callable = lambda p: True
     get_links.new_callable = []
     sys.argv = ['pep438', 'p1', 'p2']
     with patch_io() as new:
         main()
         self.assertEqual(new.stderr.getvalue(), "")
         self.assertEqual(new.stdout.getvalue(),
                          "\u2717 p1: 0 links\n\u2717 p2: 0 links\n")
示例#6
0
 def test_invalid_package(self, valid_package, get_links):
     valid_package.side_effect = lambda p: p != 'invalid'
     get_links.new_callable = []
     sys.argv = ['pep438', 'valid', 'invalid']
     with patch_io() as new:
         main()
         self.assertEqual(new.stderr.getvalue(),
                          "\u2717 invalid: not found on PyPI\n")
         self.assertEqual(new.stdout.getvalue(), "\u2717 valid: 0 links\n")
示例#7
0
 def test_pypi_user(self, user_packages):
     user_packages.side_effect = lambda u: ['p1']
     sys.argv = ['pep438', '-u', 'testuser']
     with patch_io() as new:
         main()
         user_packages.assert_called_once_with('testuser')
         self.valid_package.assert_called_once_with('p1')
         self.get_urls.called_once_with('p1')
         self.assertEqual(new.stdout.getvalue(), "\u2713 p1: 0 URLs\n")
示例#8
0
 def test_errors_only(self):
     sys.argv = ['pep438', '--errors-only', 'p1', 'p2']
     self.get_urls.side_effect = lambda p: ['1', '2'] if p == 'p1' else []
     with patch_io() as new:
         main()
         self.assertEqual(self.valid_package.call_count, 2)
         self.assertEqual(self.get_urls.call_count, 2)
         self.assertEqual(new.stderr.getvalue(), "")
         self.assertEqual(new.stdout.getvalue(), "\u2717 p1: 2 URLs\n")
示例#9
0
 def test_valid_package(self):
     sys.argv = ['pep438', 'p1', 'p2']
     with patch_io() as new:
         main()
         self.assertEqual(self.valid_package.call_count, 2)
         self.assertEqual(self.get_urls.call_count, 2)
         self.assertEqual(new.stderr.getvalue(), "")
         self.assertEqual(new.stdout.getvalue(),
                          "\u2713 p1: 0 URLs\n\u2713 p2: 0 URLs\n")
示例#10
0
 def test_invalid_package(self, valid_package, get_links):
     valid_package.side_effect = lambda p: p != 'invalid'
     get_links.new_callable = []
     sys.argv = ['pep438', 'valid', 'invalid']
     with patch_io() as new:
         main()
         self.assertEqual(new.stderr.getvalue(),
                          "\u2717 invalid: not found on PyPI\n")
         self.assertEqual(new.stdout.getvalue(),
                          "\u2717 valid: 0 links\n")
示例#11
0
 def test_invalid_package(self):
     self.valid_package.side_effect = lambda p: p != 'invalid'
     sys.argv = ['pep438', 'valid', 'invalid']
     with patch_io() as new:
         main()
         self.assertEqual(self.valid_package.call_count, 2)
         self.assertEqual(self.get_urls.call_count, 1)
         self.assertEqual(new.stderr.getvalue(),
                          "\u26a0 invalid: not found on PyPI\n")
         self.assertEqual(new.stdout.getvalue(), "\u2713 valid: 0 URLs\n")
示例#12
0
 def test_stdin(self):
     sys.argv = ['pep438']
     with patch_io() as new:
         new.stdin.write('p1\np2\n')
         new.stdin.seek(0)
         main()
         self.assertEqual(self.valid_package.call_count, 2)
         self.assertEqual(self.get_urls.call_count, 2)
         self.assertEqual(new.stderr.getvalue(), "")
         self.assertEqual(new.stdout.getvalue(),
                          "\u2713 p1: 0 URLs\n\u2713 p2: 0 URLs\n")
示例#13
0
 def test_invalid_package(self):
     self.valid_package.side_effect = lambda p: p != 'invalid'
     sys.argv = ['pep438', 'valid', 'invalid']
     with patch_io() as new:
         main()
         self.assertEqual(self.valid_package.call_count, 2)
         self.assertEqual(self.get_urls.call_count, 1)
         self.assertEqual(new.stderr.getvalue(),
                          "\u26a0 invalid: not found on PyPI\n")
         self.assertEqual(new.stdout.getvalue(),
                          "\u2713 valid: 0 URLs\n")
示例#14
0
 def test_stdin(self):
     sys.argv = ['pep438']
     with patch_io() as new:
         new.stdin.write('p1\np2\n')
         new.stdin.seek(0)
         main()
         self.assertEqual(self.valid_package.call_count, 2)
         self.assertEqual(self.get_urls.call_count, 2)
         self.assertEqual(new.stderr.getvalue(), "")
         self.assertEqual(new.stdout.getvalue(),
                          "\u2713 p1: 0 URLs\n\u2713 p2: 0 URLs\n")
示例#15
0
#!/usr/bin/env python

from pep438.main import main

if __name__ == "__main__":
    main()
示例#16
0
文件: main.py 项目: dobrite/pep438
#!/usr/bin/env python


from pep438.main import main


if __name__ == "__main__":
    main()