Merge pull request #401 from adam111316/feature/ChangePrintStatements

Change py2 print statements to py2/3 compatible functions
This commit is contained in:
adam111316 2015-06-09 19:55:37 +08:00
commit f081fa7f71
19 changed files with 110 additions and 91 deletions

View file

@ -32,6 +32,7 @@
* Change py2 exception clauses to py2/3 compatible clauses * Change py2 exception clauses to py2/3 compatible clauses
* Add py2/3 regression testing for exception clauses * Add py2/3 regression testing for exception clauses
* Change add 'hevc', 'x265' and some langs to Config Search/Episode Search/Ignore result with any word. * Change add 'hevc', 'x265' and some langs to Config Search/Episode Search/Ignore result with any word.
* Change py2 print statements to py2/3 compatible functions
[develop changelog] [develop changelog]
* Update Requests library 2.7.0 (ab1f493) to 2.7.0 (8b5e457) * Update Requests library 2.7.0 (ab1f493) to 2.7.0 (8b5e457)

View file

@ -18,6 +18,7 @@
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. # along with SickGear. If not, see <http://www.gnu.org/licenses/>.
# Check needed software dependencies to nudge users to fix their setup # Check needed software dependencies to nudge users to fix their setup
from __future__ import print_function
from __future__ import with_statement from __future__ import with_statement
import time import time
@ -32,7 +33,7 @@ import threading
import getopt import getopt
if sys.version_info < (2, 6): if sys.version_info < (2, 6):
print 'Sorry, requires Python 2.6 or 2.7.' print('Sorry, requires Python 2.6 or 2.7.')
sys.exit(1) sys.exit(1)
try: try:
@ -41,10 +42,10 @@ try:
if Cheetah.Version[0] != '2': if Cheetah.Version[0] != '2':
raise ValueError raise ValueError
except ValueError: except ValueError:
print 'Sorry, requires Python module Cheetah 2.1.0 or newer.' print('Sorry, requires Python module Cheetah 2.1.0 or newer.')
sys.exit(1) sys.exit(1)
except: except:
print 'The Python module Cheetah is required' print('The Python module Cheetah is required')
sys.exit(1) sys.exit(1)
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'))) sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib')))
@ -146,8 +147,8 @@ class SickGear(object):
# On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError # On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError
sys.setdefaultencoding(sickbeard.SYS_ENCODING) sys.setdefaultencoding(sickbeard.SYS_ENCODING)
except: except:
print 'Sorry, you MUST add the SickGear folder to the PYTHONPATH environment variable' print('Sorry, you MUST add the SickGear folder to the PYTHONPATH environment variable')
print 'or find another way to force Python to use %s for string encoding.' % sickbeard.SYS_ENCODING print('or find another way to force Python to use %s for string encoding.' % sickbeard.SYS_ENCODING)
sys.exit(1) sys.exit(1)
# Need console logging for SickBeard.py and SickBeard-console.exe # Need console logging for SickBeard.py and SickBeard-console.exe
@ -231,7 +232,7 @@ class SickGear(object):
else: else:
if self.consoleLogging: if self.consoleLogging:
print u'Not running in daemon mode. PID file creation disabled' print(u'Not running in daemon mode. PID file creation disabled')
self.CREATEPID = False self.CREATEPID = False
@ -260,11 +261,11 @@ class SickGear(object):
os.chdir(sickbeard.DATA_DIR) os.chdir(sickbeard.DATA_DIR)
if self.consoleLogging: if self.consoleLogging:
print u'Starting up SickGear from %s' % sickbeard.CONFIG_FILE print(u'Starting up SickGear from %s' % sickbeard.CONFIG_FILE)
# Load the config and publish it to the sickbeard package # Load the config and publish it to the sickbeard package
if not os.path.isfile(sickbeard.CONFIG_FILE): if not os.path.isfile(sickbeard.CONFIG_FILE):
print u'Unable to find "%s", all settings will be default!' % sickbeard.CONFIG_FILE print(u'Unable to find "%s", all settings will be default!' % sickbeard.CONFIG_FILE)
sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE) sickbeard.CFG = ConfigObj(sickbeard.CONFIG_FILE)
@ -272,12 +273,12 @@ class SickGear(object):
if CUR_DB_VERSION > 0: if CUR_DB_VERSION > 0:
if CUR_DB_VERSION < MIN_DB_VERSION: if CUR_DB_VERSION < MIN_DB_VERSION:
print u'Your database version (%s) is too old to migrate from with this version of SickGear' \ print(u'Your database version (%s) is too old to migrate from with this version of SickGear' \
% CUR_DB_VERSION % CUR_DB_VERSION)
sys.exit(u'Upgrade using a previous version of SG first, or start with no database file to begin fresh') sys.exit(u'Upgrade using a previous version of SG first, or start with no database file to begin fresh')
if CUR_DB_VERSION > MAX_DB_VERSION: if CUR_DB_VERSION > MAX_DB_VERSION:
print u'Your database version (%s) has been incremented past what this version of SickGear supports' \ print(u'Your database version (%s) has been incremented past what this version of SickGear supports' \
% CUR_DB_VERSION % CUR_DB_VERSION)
sys.exit( sys.exit(
u'If you have used other forks of SG, your database may be unusable due to their modifications') u'If you have used other forks of SG, your database may be unusable due to their modifications')

View file

@ -18,6 +18,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. # along with SickGear. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from __future__ import with_statement from __future__ import with_statement
import os.path import os.path
@ -132,7 +133,7 @@ def processEpisode(dir_to_process, org_NZB_name=None, status=None):
sess.post(login_url, data={'username': username, 'password': password}, stream=True, verify=False) sess.post(login_url, data={'username': username, 'password': password}, stream=True, verify=False)
result = sess.get(url, params=params, stream=True, verify=False) result = sess.get(url, params=params, stream=True, verify=False)
if result.status_code == 401: if result.status_code == 401:
print 'Verify and use correct username and password in autoProcessTV.cfg' print('Verify and use correct username and password in autoProcessTV.cfg')
else: else:
for line in result.iter_lines(): for line in result.iter_lines():
if line: if line:

View file

@ -19,12 +19,13 @@
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. # along with SickGear. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import sys import sys
import autoProcessTV import autoProcessTV
if len(sys.argv) < 4: if len(sys.argv) < 4:
print 'No folder supplied - is this being called from HellaVCR?' print('No folder supplied - is this being called from HellaVCR?')
sys.exit() sys.exit()
else: else:
autoProcessTV.processEpisode(sys.argv[3], sys.argv[2]) autoProcessTV.processEpisode(sys.argv[3], sys.argv[2])

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
from __future__ import print_function
import sys import sys
import os import os
import time import time
@ -23,8 +24,10 @@ try:
config.readfp(fp) config.readfp(fp)
fp.close() fp.close()
except IOError as e: except IOError as e:
print 'Could not find/read Sickbeard config.ini: ' + str(e) print('Could not find/read Sickbeard config.ini: ' + str(e))
print 'Possibly wrong mediaToSickbeard.py location. Ensure the file is in the autoProcessTV subdir of your Sickbeard installation' print(
'Possibly wrong mediaToSickbeard.py location. Ensure the file is in the autoProcessTV subdir of your Sickbeard '
'installation')
time.sleep(3) time.sleep(3)
sys.exit(1) sys.exit(1)
@ -41,7 +44,7 @@ logfile = os.path.join(logdir, 'sickbeard.log')
try: try:
handler = logging.FileHandler(logfile) handler = logging.FileHandler(logfile)
except: except:
print 'Unable to open/create the log file at ' + logfile print('Unable to open/create the log file at ' + logfile)
time.sleep(3) time.sleep(3)
sys.exit() sys.exit()
@ -53,7 +56,7 @@ def utorrent():
# print 'Calling utorrent' # print 'Calling utorrent'
if len(sys.argv) < 2: if len(sys.argv) < 2:
scriptlogger.error('No folder supplied - is this being called from uTorrent?') scriptlogger.error('No folder supplied - is this being called from uTorrent?')
print 'No folder supplied - is this being called from uTorrent?' print('No folder supplied - is this being called from uTorrent?')
time.sleep(3) time.sleep(3)
sys.exit() sys.exit()
@ -73,7 +76,7 @@ def deluge():
if len(sys.argv) < 4: if len(sys.argv) < 4:
scriptlogger.error('No folder supplied - is this being called from Deluge?') scriptlogger.error('No folder supplied - is this being called from Deluge?')
print 'No folder supplied - is this being called from Deluge?' print('No folder supplied - is this being called from Deluge?')
time.sleep(3) time.sleep(3)
sys.exit() sys.exit()
@ -86,7 +89,7 @@ def blackhole():
if None != os.getenv('TR_TORRENT_DIR'): if None != os.getenv('TR_TORRENT_DIR'):
scriptlogger.debug('Processing script triggered by Transmission') scriptlogger.debug('Processing script triggered by Transmission')
print 'Processing script triggered by Transmission' print('Processing script triggered by Transmission')
scriptlogger.debug(u'TR_TORRENT_DIR: ' + os.getenv('TR_TORRENT_DIR')) scriptlogger.debug(u'TR_TORRENT_DIR: ' + os.getenv('TR_TORRENT_DIR'))
scriptlogger.debug(u'TR_TORRENT_NAME: ' + os.getenv('TR_TORRENT_NAME')) scriptlogger.debug(u'TR_TORRENT_NAME: ' + os.getenv('TR_TORRENT_NAME'))
dirName = os.getenv('TR_TORRENT_DIR') dirName = os.getenv('TR_TORRENT_DIR')
@ -94,7 +97,7 @@ def blackhole():
else: else:
if len(sys.argv) < 2: if len(sys.argv) < 2:
scriptlogger.error('No folder supplied - Your client should invoke the script with a Dir and a Relese Name') scriptlogger.error('No folder supplied - Your client should invoke the script with a Dir and a Relese Name')
print 'No folder supplied - Your client should invoke the script with a Dir and a Release Name' print('No folder supplied - Your client should invoke the script with a Dir and a Release Name')
time.sleep(3) time.sleep(3)
sys.exit() sys.exit()
@ -127,13 +130,13 @@ def main():
if not use_torrents: if not use_torrents:
scriptlogger.error(u'Enable Use Torrent on Sickbeard to use this Script. Aborting!') scriptlogger.error(u'Enable Use Torrent on Sickbeard to use this Script. Aborting!')
print u'Enable Use Torrent on Sickbeard to use this Script. Aborting!' print(u'Enable Use Torrent on Sickbeard to use this Script. Aborting!')
time.sleep(3) time.sleep(3)
sys.exit() sys.exit()
if not torrent_method in ['utorrent', 'transmission', 'deluge', 'blackhole']: if not torrent_method in ['utorrent', 'transmission', 'deluge', 'blackhole']:
scriptlogger.error(u'Unknown Torrent Method. Aborting!') scriptlogger.error(u'Unknown Torrent Method. Aborting!')
print u'Unknown Torrent Method. Aborting!' print(u'Unknown Torrent Method. Aborting!')
time.sleep(3) time.sleep(3)
sys.exit() sys.exit()
@ -141,13 +144,13 @@ def main():
if dirName is None: if dirName is None:
scriptlogger.error(u'MediaToSickbeard script need a dir to be run. Aborting!') scriptlogger.error(u'MediaToSickbeard script need a dir to be run. Aborting!')
print u'MediaToSickbeard script need a dir to be run. Aborting!' print(u'MediaToSickbeard script need a dir to be run. Aborting!')
time.sleep(3) time.sleep(3)
sys.exit() sys.exit()
if not os.path.isdir(dirName): if not os.path.isdir(dirName):
scriptlogger.error(u'Folder ' + dirName + ' does not exist. Aborting AutoPostProcess.') scriptlogger.error(u'Folder ' + dirName + ' does not exist. Aborting AutoPostProcess.')
print u'Folder ' + dirName + ' does not exist. Aborting AutoPostProcess.' print(u'Folder ' + dirName + ' does not exist. Aborting AutoPostProcess.')
time.sleep(3) time.sleep(3)
sys.exit() sys.exit()
@ -174,7 +177,7 @@ def main():
login_url = protocol + host + ':' + port + web_root + '/login' login_url = protocol + host + ':' + port + web_root + '/login'
scriptlogger.debug('Opening URL: ' + url + ' with params=' + str(params)) scriptlogger.debug('Opening URL: ' + url + ' with params=' + str(params))
print 'Opening URL: ' + url + ' with params=' + str(params) print('Opening URL: ' + url + ' with params=' + str(params))
try: try:
sess = requests.Session() sess = requests.Session()
@ -187,13 +190,13 @@ def main():
if response.status_code == 401: if response.status_code == 401:
scriptlogger.error(u'Verify and use correct username and password in autoProcessTV.cfg') scriptlogger.error(u'Verify and use correct username and password in autoProcessTV.cfg')
print 'Verify and use correct username and password in autoProcessTV.cfg' print('Verify and use correct username and password in autoProcessTV.cfg')
time.sleep(3) time.sleep(3)
sys.exit() sys.exit()
if response.status_code == 200: if response.status_code == 200:
scriptlogger.info(u'Script ' + __file__ + ' Succesfull') scriptlogger.info(u'Script ' + __file__ + ' Succesfull')
print 'Script ' + __file__ + ' Succesfull' print('Script ' + __file__ + ' Succesfull')
time.sleep(3) time.sleep(3)
sys.exit() sys.exit()

View file

@ -19,11 +19,12 @@
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. # along with SickGear. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import sys import sys
import autoProcessTV import autoProcessTV
if len(sys.argv) < 2: if len(sys.argv) < 2:
print 'No folder supplied - is this being called from SABnzbd?' print('No folder supplied - is this being called from SABnzbd?')
sys.exit() sys.exit()
elif len(sys.argv) >= 8: elif len(sys.argv) >= 8:
autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], sys.argv[7]) autoProcessTV.processEpisode(sys.argv[1], sys.argv[2], sys.argv[7])

View file

@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. # along with SickGear. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from __future__ import with_statement from __future__ import with_statement
import getpass import getpass
import os import os
@ -777,7 +778,7 @@ def get_lan_ip():
for ifname in interfaces: for ifname in interfaces:
try: try:
ip = get_interface_ip(ifname) ip = get_interface_ip(ifname)
print ifname, ip print(ifname, ip)
break break
except IOError: except IOError:
pass pass

View file

@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. # along with SickGear. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import socket import socket
import sickbeard import sickbeard
@ -80,7 +81,7 @@ class GrowlNotifier:
return False return False
def _send(self, host, port, data, debug=False): def _send(self, host, port, data, debug=False):
if debug: print '<Sending>\n', data, '\n</Sending>' if debug: print('<Sending>\n', data, '\n</Sending>')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port)) s.connect((host, port))
@ -88,7 +89,7 @@ class GrowlNotifier:
response = gntp.parse_gntp(s.recv(1024)) response = gntp.parse_gntp(s.recv(1024))
s.close() s.close()
if debug: print '<Recieved>\n', response, '\n</Recieved>' if debug: print('<Recieved>\n', response, '\n</Recieved>')
return response return response

View file

@ -18,6 +18,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. # along with SickGear. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
if __name__ == "__main__": if __name__ == "__main__":
import glob import glob
import unittest import unittest
@ -28,12 +29,12 @@ if __name__ == "__main__":
suites = [unittest.defaultTestLoader.loadTestsFromName(file_string) for file_string in module_strings] suites = [unittest.defaultTestLoader.loadTestsFromName(file_string) for file_string in module_strings]
testSuite = unittest.TestSuite(suites) testSuite = unittest.TestSuite(suites)
print "==================" print('==================')
print "STARTING - ALL TESTS" print('STARTING - ALL TESTS')
print "==================" print('==================')
print "this will include" print('this will include')
for includedfiles in test_file_strings: for includedfiles in test_file_strings:
print "- " + includedfiles print('- ' + includedfiles)
text_runner = unittest.TextTestRunner().run(testSuite) text_runner = unittest.TextTestRunner().run(testSuite)
if not text_runner.wasSuccessful(): if not text_runner.wasSuccessful():

View file

@ -16,7 +16,7 @@ class CompatibilityTests(unittest.TestCase):
pyfiles.append(os.path.join(path,'SickBeard.py')) pyfiles.append(os.path.join(path,'SickBeard.py'))
output = subprocess.Popen('2to3 -f except %s' % ' '.join(pyfiles), shell=True, stdout=subprocess.PIPE, output = subprocess.Popen('2to3 -f except -f print -p %s' % ' '.join(pyfiles), shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE).communicate()[0] stderr=subprocess.PIPE).communicate()[0]
if output: if output:
print('Changes to be made for Python 2/3 compatibility as follows:') print('Changes to be made for Python 2/3 compatibility as follows:')

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. # along with SickGear. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import unittest import unittest
import test_lib as test import test_lib as test
@ -32,9 +33,9 @@ class DBBasicTests(test.SickbeardTestDBCase):
self.db.close() self.db.close()
if __name__ == '__main__': if __name__ == '__main__':
print "==================" print('==================')
print "STARTING - DB TESTS" print('STARTING - DB TESTS')
print "==================" print('==================')
print "######################################################################" print('######################################################################')
suite = unittest.TestLoader().loadTestsFromTestCase(DBBasicTests) suite = unittest.TestLoader().loadTestsFromTestCase(DBBasicTests)
unittest.TextTestRunner(verbosity=2).run(suite) unittest.TextTestRunner(verbosity=2).run(suite)

View file

@ -1,3 +1,4 @@
from __future__ import print_function
import sys import sys
import os.path import os.path
import glob import glob
@ -107,9 +108,9 @@ class AddDefaultEpStatusToTvShows(db.SchemaUpgrade):
if __name__ == '__main__': if __name__ == '__main__':
print '==================' print('==================')
print 'Starting - Migration Tests' print('Starting - Migration Tests')
print '==================' print('==================')
print '######################################################################' print('######################################################################')
suite = unittest.TestLoader().loadTestsFromTestCase(MigrationBasicTests) suite = unittest.TestLoader().loadTestsFromTestCase(MigrationBasicTests)
unittest.TextTestRunner(verbosity=2).run(suite) unittest.TextTestRunner(verbosity=2).run(suite)

View file

@ -1,3 +1,4 @@
from __future__ import print_function
import datetime import datetime
import unittest import unittest
import test_lib as test import test_lib as test
@ -266,7 +267,7 @@ class FailureCaseTests(test.SickbeardTestDBCase):
return True return True
if VERBOSE: if VERBOSE:
print 'Actual: ', parse_result.which_regex, parse_result print('Actual: ', parse_result.which_regex, parse_result)
return False return False
def test_failures(self): def test_failures(self):
@ -278,8 +279,8 @@ class ComboTests(test.SickbeardTestDBCase):
def _test_combo(self, name, result, which_regexes): def _test_combo(self, name, result, which_regexes):
if VERBOSE: if VERBOSE:
print print()
print 'Testing', name print('Testing', name)
np = parser.NameParser(True) np = parser.NameParser(True)
@ -289,8 +290,8 @@ class ComboTests(test.SickbeardTestDBCase):
return False return False
if DEBUG: if DEBUG:
print test_result, test_result.which_regex print(test_result, test_result.which_regex)
print result, which_regexes print(result, which_regexes)
self.assertEqual(test_result, result) self.assertEqual(test_result, result)
for cur_regex in which_regexes: for cur_regex in which_regexes:
@ -309,15 +310,14 @@ class BasicTests(test.SickbeardTestDBCase):
def _test_names(self, np, section, transform=None, verbose=False): def _test_names(self, np, section, transform=None, verbose=False):
if VERBOSE or verbose: if VERBOSE or verbose:
print print('Running', section, 'tests')
print 'Running', section, 'tests'
for cur_test_base in simple_test_cases[section]: for cur_test_base in simple_test_cases[section]:
if transform: if transform:
cur_test = transform(cur_test_base) cur_test = transform(cur_test_base)
else: else:
cur_test = cur_test_base cur_test = cur_test_base
if VERBOSE or verbose: if VERBOSE or verbose:
print 'Testing', cur_test print('Testing', cur_test)
result = simple_test_cases[section][cur_test_base] result = simple_test_cases[section][cur_test_base]
if not result: if not result:
@ -330,10 +330,10 @@ class BasicTests(test.SickbeardTestDBCase):
# self.assertEqual(test_result.which_regex, [section]) # self.assertEqual(test_result.which_regex, [section])
self.assertEqual(test_result, result) self.assertEqual(test_result, result)
except: except:
print 'air_by_date:', test_result.is_air_by_date, 'air_date:', test_result.air_date print('air_by_date:', test_result.is_air_by_date, 'air_date:', test_result.air_date)
print 'anime:', test_result.is_anime, 'ab_episode_numbers:', test_result.ab_episode_numbers print('anime:', test_result.is_anime, 'ab_episode_numbers:', test_result.ab_episode_numbers)
print test_result print(test_result)
print result print(result)
raise raise

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. # along with SickGear. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import random import random
import unittest import unittest
@ -62,12 +63,12 @@ class PPBasicTests(test.SickbeardTestDBCase):
if __name__ == '__main__': if __name__ == '__main__':
print "==================" print('==================')
print "STARTING - PostProcessor TESTS" print('STARTING - PostProcessor TESTS')
print "==================" print('==================')
print "######################################################################" print('######################################################################')
suite = unittest.TestLoader().loadTestsFromTestCase(PPInitTests) suite = unittest.TestLoader().loadTestsFromTestCase(PPInitTests)
unittest.TextTestRunner(verbosity=2).run(suite) unittest.TextTestRunner(verbosity=2).run(suite)
print "######################################################################" print('######################################################################')
suite = unittest.TestLoader().loadTestsFromTestCase(PPBasicTests) suite = unittest.TestLoader().loadTestsFromTestCase(PPBasicTests)
unittest.TextTestRunner(verbosity=2).run(suite) unittest.TextTestRunner(verbosity=2).run(suite)

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. # along with SickGear. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import random import random
import unittest import unittest
@ -88,10 +89,10 @@ def test_generator(tvdbdid, show_name, curData, forceSearch):
return test return test
if __name__ == '__main__': if __name__ == '__main__':
print "==================" print('==================')
print "STARTING - Snatch TESTS" print('STARTING - Snatch TESTS')
print "==================" print('==================')
print "######################################################################" print('######################################################################')
# create the test methods # create the test methods
tvdbdid = 1 tvdbdid = 1
for forceSearch in (True, False): for forceSearch in (True, False):

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. # along with SickGear. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from __future__ import with_statement from __future__ import with_statement
import unittest import unittest
@ -208,7 +209,7 @@ def setUp_test_episode_file():
with open(FILEPATH, 'w') as f: with open(FILEPATH, 'w') as f:
f.write("foo bar") f.write("foo bar")
except EnvironmentError: except EnvironmentError:
print "Unable to set up test episode" print('Unable to set up test episode')
raise raise
@ -229,15 +230,15 @@ def tearDown_test_show_dir():
tearDown_test_db() tearDown_test_db()
if __name__ == '__main__': if __name__ == '__main__':
print "==================" print('==================')
print "Dont call this directly" print('Dont call this directly')
print "==================" print('==================')
print "you might want to call" print('you might want to call')
dirList = os.listdir(TESTDIR) dirList = os.listdir(TESTDIR)
for fname in dirList: for fname in dirList:
if (fname.find("_test") > 0) and (fname.find("pyc") < 0): if (fname.find("_test") > 0) and (fname.find("pyc") < 0):
print "- " + fname print('- ' + fname)
print "==================" print('==================')
print "or just call all_tests.py" print('or just call all_tests.py')

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. # along with SickGear. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from __future__ import with_statement from __future__ import with_statement
import unittest import unittest
@ -68,11 +69,11 @@ class TorrentBasicTests(test.SickbeardTestDBCase):
except (AttributeError, TypeError): except (AttributeError, TypeError):
continue continue
print title print(title)
if __name__ == "__main__": if __name__ == "__main__":
print "==================" print('==================')
print "STARTING - XEM Scene Numbering TESTS" print('STARTING - XEM Scene Numbering TESTS')
print "==================" print('==================')
print "######################################################################" print('######################################################################')
suite = unittest.TestLoader().loadTestsFromTestCase(TorrentBasicTests) suite = unittest.TestLoader().loadTestsFromTestCase(TorrentBasicTests)

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. # along with SickGear. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import unittest import unittest
import test_lib as test import test_lib as test
@ -98,15 +99,15 @@ class TVTests(test.SickbeardTestDBCase):
if __name__ == '__main__': if __name__ == '__main__':
print "==================" print('==================')
print "STARTING - TV TESTS" print('STARTING - TV TESTS')
print "==================" print('==================')
print "######################################################################" print('######################################################################')
suite = unittest.TestLoader().loadTestsFromTestCase(TVShowTests) suite = unittest.TestLoader().loadTestsFromTestCase(TVShowTests)
unittest.TextTestRunner(verbosity=2).run(suite) unittest.TextTestRunner(verbosity=2).run(suite)
print "######################################################################" print('######################################################################')
suite = unittest.TestLoader().loadTestsFromTestCase(TVEpisodeTests) suite = unittest.TestLoader().loadTestsFromTestCase(TVEpisodeTests)
unittest.TextTestRunner(verbosity=2).run(suite) unittest.TextTestRunner(verbosity=2).run(suite)
print "######################################################################" print('######################################################################')
suite = unittest.TestLoader().loadTestsFromTestCase(TVTests) suite = unittest.TestLoader().loadTestsFromTestCase(TVTests)
unittest.TextTestRunner(verbosity=2).run(suite) unittest.TextTestRunner(verbosity=2).run(suite)

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with SickGear. If not, see <http://www.gnu.org/licenses/>. # along with SickGear. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from __future__ import with_statement from __future__ import with_statement
import unittest import unittest
@ -62,7 +63,7 @@ class XEMBasicTests(test.SickbeardTestDBCase):
curShow = TVShow(int(sqlShow["indexer"]), int(sqlShow["indexer_id"])) curShow = TVShow(int(sqlShow["indexer"]), int(sqlShow["indexer_id"]))
sickbeard.showList.append(curShow) sickbeard.showList.append(curShow)
except Exception as e: except Exception as e:
print "There was an error creating the show" print('There was an error creating the show')
def test_formating(self): def test_formating(self):
name = "Game.of.Thrones.S03.720p.HDTV.x264-CtrlHD" name = "Game.of.Thrones.S03.720p.HDTV.x264-CtrlHD"
@ -80,8 +81,8 @@ class XEMBasicTests(test.SickbeardTestDBCase):
if __name__ == "__main__": if __name__ == "__main__":
print "==================" print('==================')
print "STARTING - XEM Scene Numbering TESTS" print('STARTING - XEM Scene Numbering TESTS')
print "==================" print('==================')
print "######################################################################" print('######################################################################')
suite = unittest.TestLoader().loadTestsFromTestCase(XEMBasicTests) suite = unittest.TestLoader().loadTestsFromTestCase(XEMBasicTests)