Commit eb2b5c5c authored by Andrea Azzarone's avatar Andrea Azzarone 🚴

tests: Port tests to python3

parent f4f5b780
......@@ -64,14 +64,14 @@ class AbstractTextEngine:
def send_data_cb (self):
sparql = self.get_insert_sparql ()
self.iface.SparqlUpdate (sparql)
print int(time.time()), self.msgsize, self.publicname
print(int(time.time()), self.msgsize, self.publicname)
return True
def get_insert_sparql (self):
print "Implement this method in a subclass!!!"
print("Implement this method in a subclass!!!")
assert False
def get_running_label (self):
print "Implement this method in a subclass!!!"
print("Implement this method in a subclass!!!")
assert False
......@@ -47,23 +47,23 @@ def run_query ():
start = time.time ()
results = iface.SparqlQuery (SPARQL_QUERY % ("10"))
end = time.time ()
print int (time.time()), "%f" % (end - start)
print(int (time.time()), "%f" % (end - start))
return True
def exit_cb ():
sys.exit (0)
def usage ():
print "Usage:"
print " client.py [OPTION...] - Run periodically a query on tracker"
print ""
print "Help Options:"
print " -h, --help Show help options"
print ""
print "Application Options:"
print " -p, --period=NUM Time (in sec) between queries"
print " -t, --timeout=NUM Switch off the program after NUM seconds"
print ""
print("Usage:")
print(" client.py [OPTION...] - Run periodically a query on tracker")
print("")
print("Help Options:")
print(" -h, --help Show help options")
print("")
print("Application Options:")
print(" -p, --period=NUM Time (in sec) between queries")
print(" -t, --timeout=NUM Switch off the program after NUM seconds")
print("")
if __name__ == "__main__":
......
......@@ -22,18 +22,18 @@ import getopt
import sys
def usage ():
print "Usage:"
print " xxx.py [OPTION...] - Input data into tracker"
print ""
print "Help Options:"
print " -h, --help Show help options"
print ""
print "Application Options:"
print " -g, --graphics Enable GTK interface"
print " -p, --period=NUM Time (in sec) between insertion message"
print " -s, --size=NUM Amount of instances in the message"
print " -t, --timeout=NUM Switch off the program after NUM seconds"
print ""
print("Usage:")
print(" xxx.py [OPTION...] - Input data into tracker")
print("")
print("Help Options:")
print(" -h, --help Show help options")
print("")
print("Application Options:")
print(" -g, --graphics Enable GTK interface")
print(" -p, --period=NUM Time (in sec) between insertion message")
print(" -s, --size=NUM Amount of instances in the message")
print(" -t, --timeout=NUM Switch off the program after NUM seconds")
print("")
def parse_options (graphic_mode=False, period=1, msgsize=1, timeout=0):
......@@ -41,9 +41,9 @@ def parse_options (graphic_mode=False, period=1, msgsize=1, timeout=0):
opts, args = getopt.getopt(sys.argv[1:],
"gp:s:t:h",
["graphics", "period", "size", "timeout", "help"])
except getopt.GetoptError, err:
except getopt.GetoptError as err:
# print help information and exit:
print str (err) # will print something like "option -a not recognized"
print(str (err)) # will print something like "option -a not recognized"
usage ()
sys.exit (2)
......
......@@ -54,7 +54,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
nie:url \"%s\" .
}
""" % (self.uri (filepath)))
self.assertEquals (len (result), 1)
self.assertEqual (len (result), 1)
return result[0][0]
def __get_file_urn (self, filepath):
......@@ -64,7 +64,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
nie:url \"%s\" .
}
""" % (self.uri (filepath)))
self.assertEquals (len (result), 1)
self.assertEqual (len (result), 1)
return result[0][0]
"""
......@@ -75,7 +75,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
The precreated files and folders should be there
"""
result = self.__get_text_documents ()
self.assertEquals (len (result), 3)
self.assertEqual (len (result), 3)
unpacked_result = [ r[0] for r in result]
self.assertIn ( self.uri ("test-monitored/file1.txt"), unpacked_result)
self.assertIn ( self.uri ("test-monitored/dir1/file2.txt"), unpacked_result)
......@@ -102,7 +102,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
# verify if miner indexed this file.
result = self.__get_text_documents ()
self.assertEquals (len (result), 4)
self.assertEqual (len (result), 4)
unpacked_result = [ r[0] for r in result]
self.assertIn ( self.uri ("test-monitored/file1.txt"), unpacked_result)
self.assertIn ( self.uri ("test-monitored/dir1/file2.txt"), unpacked_result)
......@@ -128,7 +128,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
time.sleep (1)
# Nothing changed
result = self.__get_text_documents ()
self.assertEquals (len (result), 3, "Results:" + str(result))
self.assertEqual (len (result), 3, "Results:" + str(result))
unpacked_result = [ r[0] for r in result]
self.assertIn ( self.uri ("test-monitored/file1.txt"), unpacked_result)
self.assertIn ( self.uri ("test-monitored/dir1/file2.txt"), unpacked_result)
......@@ -148,7 +148,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
dest_id, dest_urn = self.system.store.await_resource_inserted (NFO_DOCUMENT, self.uri(dest))
result = self.__get_text_documents ()
self.assertEquals (len (result), 4)
self.assertEqual (len (result), 4)
unpacked_result = [ r[0] for r in result]
self.assertIn ( self.uri ("test-monitored/file1.txt"), unpacked_result)
self.assertIn ( self.uri ("test-monitored/dir1/file2.txt"), unpacked_result)
......@@ -158,7 +158,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
# Clean the file
os.remove (dest)
self.system.store.await_resource_deleted (NFO_DOCUMENT, dest_id)
self.assertEquals (3, self.tracker.count_instances ("nfo:TextDocument"))
self.assertEqual (3, self.tracker.count_instances ("nfo:TextDocument"))
@ut.skip("https://gitlab.gnome.org/GNOME/tracker-miners/issues/56")
......@@ -172,7 +172,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
dest_id, dest_urn = self.system.store.await_resource_inserted (NFO_DOCUMENT, self.uri(dest))
result = self.__get_text_documents ()
self.assertEquals (len (result), 4)
self.assertEqual (len (result), 4)
unpacked_result = [ r[0] for r in result]
self.assertIn ( self.uri ("test-monitored/file1.txt"), unpacked_result)
self.assertIn ( self.uri ("test-monitored/dir1/file2.txt"), unpacked_result)
......@@ -182,7 +182,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
# Clean the file
os.remove (dest)
self.system.store.await_resource_deleted (NFO_DOCUMENT, dest_id)
self.assertEquals (3, self.tracker.count_instances ("nfo:TextDocument"))
self.assertEqual (3, self.tracker.count_instances ("nfo:TextDocument"))
## """ move operation and tracker-miner response test cases """
## class move(TestUpdate):
......@@ -199,7 +199,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
self.system.store.await_resource_deleted (NFO_DOCUMENT, source_id)
result = self.__get_text_documents ()
self.assertEquals (len (result), 2)
self.assertEqual (len (result), 2)
unpacked_result = [ r[0] for r in result]
self.assertIn ( self.uri ("test-monitored/file1.txt"), unpacked_result)
self.assertIn ( self.uri ("test-monitored/dir1/dir2/file3.txt"), unpacked_result)
......@@ -207,7 +207,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
# Restore the file
shutil.move (dest, source)
self.system.store.await_resource_inserted (NFO_DOCUMENT, self.uri(source))
self.assertEquals (3, self.tracker.count_instances ("nfo:TextDocument"))
self.assertEqual (3, self.tracker.count_instances ("nfo:TextDocument"))
def test_07_move_from_monitored_to_monitored (self):
......@@ -222,7 +222,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
source_dir_urn = self.__get_file_urn (os.path.dirname(source))
parent_before = self.__get_parent_urn (source)
self.assertEquals (source_dir_urn, parent_before)
self.assertEqual (source_dir_urn, parent_before)
shutil.move (source, dest)
self.tracker.await_property_changed(NFO_DOCUMENT, resource_id, 'nie:url')
......@@ -231,11 +231,11 @@ class MinerCrawlTest (CommonTrackerMinerTest):
# should be changed to the new one
dest_dir_urn = self.__get_file_urn (os.path.dirname(dest))
parent_after = self.__get_parent_urn (dest)
self.assertNotEquals (parent_before, parent_after)
self.assertEquals (dest_dir_urn, parent_after)
self.assertNotEqual (parent_before, parent_after)
self.assertEqual (dest_dir_urn, parent_after)
result = self.__get_text_documents ()
self.assertEquals (len (result), 3)
self.assertEqual (len (result), 3)
unpacked_result = [ r[0] for r in result]
self.assertIn ( self.uri ("test-monitored/file1.txt"), unpacked_result)
self.assertIn ( self.uri ("test-monitored/file2.txt"), unpacked_result)
......@@ -246,7 +246,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
self.tracker.await_property_changed(NFO_DOCUMENT, resource_id, 'nie:url')
result = self.__get_text_documents ()
self.assertEquals (len (result), 3)
self.assertEqual (len (result), 3)
unpacked_result = [ r[0] for r in result]
self.assertIn ( self.uri ("test-monitored/dir1/file2.txt"), unpacked_result)
......@@ -261,7 +261,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
self.system.store.await_resource_deleted (NFO_DOCUMENT, victim_id)
result = self.__get_text_documents ()
self.assertEquals (len (result), 2)
self.assertEqual (len (result), 2)
unpacked_result = [ r[0] for r in result]
self.assertIn ( self.uri ("test-monitored/file1.txt"), unpacked_result)
self.assertIn ( self.uri ("test-monitored/dir1/dir2/file3.txt"), unpacked_result)
......@@ -285,7 +285,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
self.system.store.await_resource_deleted (NFO_DOCUMENT, file_inside_victim_id)
result = self.__get_text_documents ()
self.assertEquals (len (result), 1)
self.assertEqual (len (result), 1)
unpacked_result = [ r[0] for r in result]
self.assertIn ( self.uri ("test-monitored/file1.txt"), unpacked_result)
......@@ -302,7 +302,7 @@ class MinerCrawlTest (CommonTrackerMinerTest):
# Check everything is fine
result = self.__get_text_documents ()
self.assertEquals (len (result), 3)
self.assertEqual (len (result), 3)
if __name__ == "__main__":
ut.main(failfast=True)
......@@ -51,11 +51,11 @@ class MinerFTSBasicTest (CommonTrackerMinerFTSTest):
self.set_text (TEXT)
results = self.search_word ("automobile")
self.assertEquals (len (results), 1)
self.assertEqual (len (results), 1)
self.assertIn (self.uri (self.testfile), results)
results = self.search_word ("unlimited")
self.assertEquals (len (results), 1)
self.assertEqual (len (results), 1)
self.assertIn (self.uri (self.testfile), results)
......@@ -65,13 +65,13 @@ class MinerFTSBasicTest (CommonTrackerMinerFTSTest):
self.set_text (TEXT)
results = self.search_word (TEXT)
self.assertEquals (len (results), 0)
self.assertEqual (len (results), 0)
def test_04_non_existent_word (self):
TEXT = "This a trick"
self.set_text (TEXT)
results = self.search_word ("trikc")
self.assertEquals (len (results), 0)
self.assertEqual (len (results), 0)
def test_05_word_multiple_times_in_file (self):
TEXT = "automobile is red. automobile is big. automobile is great!"
......@@ -101,7 +101,7 @@ class MinerFTSBasicTest (CommonTrackerMinerFTSTest):
TEXT = "palabra 123123"
self.set_text (TEXT)
results = self.search_word ("123123")
self.assertEquals (len (results), 0)
self.assertEqual (len (results), 0)
if __name__ == "__main__":
......
......@@ -57,7 +57,7 @@ class MinerFTSFileOperationsTest (CommonTrackerMinerFTSTest):
self.tracker.await_resource_deleted (NFO_DOCUMENT, id)
results = self.search_word ("automobile")
self.assertEquals (len (results), 0)
self.assertEqual (len (results), 0)
def test_02_empty_the_file (self):
"""
......@@ -68,7 +68,7 @@ class MinerFTSFileOperationsTest (CommonTrackerMinerFTSTest):
self.set_text ("")
results = self.search_word ("automobile")
self.assertEquals (len (results), 0)
self.assertEqual (len (results), 0)
@ut.skip("FIXME: this test fails!")
def test_03_update_the_file (self):
......@@ -81,10 +81,10 @@ class MinerFTSFileOperationsTest (CommonTrackerMinerFTSTest):
self.set_text ("airplane is blue and small and wonderful")
results = self.search_word ("automobile")
self.assertEquals (len (results), 0)
self.assertEqual (len (results), 0)
results = self.search_word ("airplane")
self.assertEquals (len (results), 1)
self.assertEqual (len (results), 1)
# Skip the test_text_13... feel, feet, fee in three diff files and search feet
......@@ -107,7 +107,7 @@ class MinerFTSFileOperationsTest (CommonTrackerMinerFTSTest):
self.__recreate_file (self.path (TEST_15_FILE), TEXT)
results = self.search_word ("automobile")
self.assertEquals (len (results), 0)
self.assertEqual (len (results), 0)
os.remove (self.path (TEST_15_FILE))
......@@ -125,7 +125,7 @@ class MinerFTSFileOperationsTest (CommonTrackerMinerFTSTest):
time.sleep (2)
results = self.search_word ("airplane")
self.assertEquals (len (results), 0)
self.assertEqual (len (results), 0)
shutil.copyfile (self.path (TEST_16_SOURCE), self.path (TEST_16_DEST))
self.tracker.await_resource_inserted (rdf_class = NFO_DOCUMENT,
......@@ -133,7 +133,7 @@ class MinerFTSFileOperationsTest (CommonTrackerMinerFTSTest):
required_property = 'nie:plainTextContent')
results = self.search_word ("airplane")
self.assertEquals (len (results), 1)
self.assertEqual (len (results), 1)
os.remove (self.path (TEST_16_SOURCE))
os.remove (self.path (TEST_16_DEST))
......
......@@ -71,11 +71,11 @@ class MinerFTSStopwordsTest (CommonTrackerMinerFTSTest):
self.set_text (TEXT)
results = self.search_word ("automobile")
self.assertEquals (len (results), 1)
self.assertEqual (len (results), 1)
log ("Stopwords: %s" % stopwords)
for i in range (0, len (stopwords)):
results = self.search_word (stopwords[i])
self.assertEquals (len (results), 0)
self.assertEqual (len (results), 0)
## FIXME add all the special character tests!
## http://git.gnome.org/browse/tracker/commit/?id=81c0d3bd754a6b20ac72323481767dc5b4a6217b
......
......@@ -85,11 +85,9 @@ class ExtractionTestCase (ut.TestCase):
result = get_tracker_extract_jsonld_output(self.file_to_extract)
self.__assert_extraction_ok (result)
@ut.expectedFailure
def expected_failure_test_extraction (self):
try:
self.generic_test_extraction ()
except Exception:
raise ut.case._ExpectedFailure(sys.exc_info())
self.generic_test_extraction ()
if self.__get_bugnumber ():
raise Exception ("Unexpected success. Maybe bug: " + self.__get_bugnumber () + " has been fixed?")
......@@ -99,7 +97,7 @@ class ExtractionTestCase (ut.TestCase):
def assertDictHasKey (self, d, key, msg=None):
if not isinstance(d, dict):
self.fail ("Expected dict, got %s" % d)
if not d.has_key (key):
if key not in d:
standardMsg = "Missing: %s\n" % (key)
self.fail (self._formatMessage (msg, standardMsg))
else:
......@@ -135,7 +133,7 @@ class ExtractionTestCase (ut.TestCase):
unexpected_pairs = [] # List of unexpected (key, value)
expected_keys = [] # List of expected keys (the key must be there, value doesnt matter)
for k, v in spec.items():
for k, v in list(spec.items()):
if k.startswith ("!"):
unexpected_pairs.append ( (k[1:], v) )
elif k == '@type':
......@@ -178,7 +176,7 @@ class ExtractionTestCase (ut.TestCase):
for (prop, value) in unexpected_pairs:
# There is no prop, or it is but not with that value
if (value == ""):
self.assertFalse (result.has_key (prop), error_extra_prop % (prop,
self.assertFalse (prop in result, error_extra_prop % (prop,
self.file_to_extract,
self.descfile))
else:
......@@ -213,7 +211,7 @@ def run_all ():
else:
TEST_DATA_PATH = os.path.join (cfg.DATADIR, "tracker-tests",
"test-extraction-data")
print "Loading test descriptions from", TEST_DATA_PATH
print("Loading test descriptions from", TEST_DATA_PATH)
extractionTestSuite = ut.TestSuite ()
for root, dirs, files in os.walk (TEST_DATA_PATH):
descriptions = [os.path.join (root, f) for f in files if f.endswith ("expected")]
......
......@@ -60,7 +60,7 @@ class WritebackKeepDateTest (CommonTrackerWritebackTest):
} ORDER BY ?contentCreated
"""
results = self.tracker.query (query_images)
self.assertEquals (len (results), 3, results)
self.assertEqual (len (results), 3, results)
log ("Waiting 2 seconds to ensure there is a noticiable difference in the timestamp")
time.sleep (2)
......@@ -101,8 +101,8 @@ class WritebackKeepDateTest (CommonTrackerWritebackTest):
# Indeed the order of the results should be the same
for i in range (0, len (results)):
self.assertEquals (results[i][0], new_results[i][0], "Order of the files is different")
self.assertEquals (results[i][1], new_results[i][1], "Date has change in file <%s>" % results[i][0])
self.assertEqual (results[i][0], new_results[i][0], "Order of the files is different")
self.assertEqual (results[i][1], new_results[i][1], "Date has change in file <%s>" % results[i][0])
if __name__ == "__main__":
......
......@@ -71,7 +71,7 @@ class TrackerCameraTestSuite (CommonTrackerApplicationTest):
}
""" % locals()
self.tracker.update (insert)
self.assertEquals (self.get_urn_count_by_url (file_url), 1)
self.assertEqual (self.get_urn_count_by_url (file_url), 1)
def insert_video_resource_info (self, urn, file_url):
"""
......@@ -105,7 +105,7 @@ class TrackerCameraTestSuite (CommonTrackerApplicationTest):
}
""" % locals()
self.tracker.update (insert)
self.assertEquals (self.get_urn_count_by_url (file_url), 1)
self.assertEqual (self.get_urn_count_by_url (file_url), 1)
def insert_dummy_location_info (self, fileurn, geolocationurn, postaladdressurn):
"""
......@@ -151,13 +151,13 @@ class TrackerCameraPicturesApplicationTests (TrackerCameraTestSuite):
self.slowcopy_file (origin_filepath, dest_filepath)
assert os.path.exists (dest_filepath)
dest_id, dest_urn = self.system.store.await_resource_inserted (NMM_PHOTO, dest_fileuri)
self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 1)
self.assertEqual (self.get_urn_count_by_url (dest_fileuri), 1)
# Clean the new file so the test directory is as before
log ("Remove and wait")
os.remove (dest_filepath)
self.system.store.await_resource_deleted (NMM_PHOTO, dest_id)
self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 0)
self.assertEqual (self.get_urn_count_by_url (dest_fileuri), 0)
def test_02_camera_picture_geolocation (self):
"""
......@@ -197,13 +197,13 @@ class TrackerCameraPicturesApplicationTests (TrackerCameraTestSuite):
# FOURTH, ensure we have only 1 resource
dest_id, dest_urn = self.system.store.await_resource_inserted (NMM_PHOTO, dest_fileuri)
self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 1)
self.assertEqual (self.get_urn_count_by_url (dest_fileuri), 1)
# Clean the new file so the test directory is as before
log ("Remove and wait")
os.remove (dest_filepath)
self.system.store.await_resource_deleted (NMM_PHOTO, dest_id)
self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 0)
self.assertEqual (self.get_urn_count_by_url (dest_fileuri), 0)
class TrackerCameraVideosApplicationTests (TrackerCameraTestSuite):
......@@ -229,13 +229,13 @@ class TrackerCameraVideosApplicationTests (TrackerCameraTestSuite):
self.slowcopy_file (origin_filepath, dest_filepath)
assert os.path.exists (dest_filepath)
dest_id, dest_urn = self.system.store.await_resource_inserted (NMM_PHOTO, dest_fileuri)
self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 1)
self.assertEqual (self.get_urn_count_by_url (dest_fileuri), 1)
# Clean the new file so the test directory is as before
log ("Remove and wait")
os.remove (dest_filepath)
self.system.store.await_resource_deleted (NMM_PHOTO, dest_id)
self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 0)
self.assertEqual (self.get_urn_count_by_url (dest_fileuri), 0)
def test_02_camera_video_geolocation (self):
......@@ -276,13 +276,13 @@ class TrackerCameraVideosApplicationTests (TrackerCameraTestSuite):
# FOURTH, ensure we have only 1 resource
dest_id, dest_urn = self.system.store.await_resource_inserted (NMM_VIDEO, dest_fileuri)
self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 1)
self.assertEqual (self.get_urn_count_by_url (dest_fileuri), 1)
# Clean the new file so the test directory is as before
log ("Remove and wait")
os.remove (dest_filepath)
self.system.store.await_resource_deleted (NMM_VIDEO, dest_id)
self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 0)
self.assertEqual (self.get_urn_count_by_url (dest_fileuri), 0)
if __name__ == "__main__":
ut.main()
......
......@@ -104,7 +104,7 @@ class TrackerSyncApplicationTests (CommonTrackerApplicationTest):
}
""" % (dest_fileuri, dest_fileuri)
self.tracker.update (insert)
self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 1)
self.assertEqual (self.get_urn_count_by_url (dest_fileuri), 1)
resource_id = self.tracker.get_resource_id(dest_fileuri)
......@@ -116,13 +116,13 @@ class TrackerSyncApplicationTests (CommonTrackerApplicationTest):
self.system.miner_fs.await_wakeup_count (miner_wakeup_count + 1)
self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 1)
self.assertEqual (self.get_urn_count_by_url (dest_fileuri), 1)
# Clean the new file so the test directory is as before
log ("Remove and wait")
os.remove (dest_filepath)
self.tracker.await_resource_deleted (NMM_MUSICPIECE, resource_id)
self.assertEquals (self.get_urn_count_by_url (dest_fileuri), 0)
self.assertEqual (self.get_urn_count_by_url (dest_fileuri), 0)
if __name__ == "__main__":
ut.main()
......
......@@ -65,7 +65,7 @@ class CommonTrackerApplicationTest (ut.TestCase):
log ("Copying slowly\n '%s' to\n '%s'" % (src, fdest.name))
fsrc = open (src, 'rb')
buffer_ = fsrc.read (rate)
while (buffer_ != ""):
while (buffer_ != b""):
fdest.write (buffer_)
time.sleep (0.1)
buffer_ = fsrc.read (rate)
......
......@@ -101,7 +101,7 @@ def generated_ttl_dir():
# present :/
_TEST_MONITORED_TMP_DIR = os.path.join (os.environ["HOME"], "tracker-tests")
if _TEST_MONITORED_TMP_DIR.startswith('/tmp'):
if os.environ.has_key('REAL_HOME'):
if 'REAL_HOME' in os.environ:
_TEST_MONITORED_TMP_DIR = os.path.join (os.environ["REAL_HOME"], "tracker-tests")
else:
print ("HOME is in the /tmp prefix - this will cause tests that rely " +
......
......@@ -3,7 +3,7 @@ from gi.repository import Gio
import os
from helpers import log
from common.utils.helpers import log
class DConfClient(object):
"""
......
......@@ -27,9 +27,9 @@ import subprocess
import time
import re
import configuration as cfg
import mainloop
import options
from common.utils import configuration as cfg
from common.utils import mainloop
from common.utils import options
class NoMetadataException (Exception):
pass
......
......@@ -187,7 +187,7 @@ class CommonTrackerMinerFTSTest (CommonTrackerMinerTest):
"""
self.set_text (text)
results = self.search_word (word)
self.assertEquals (len (results), 1)
self.assertEqual (len (results), 1)
self.assertIn ( self.uri (self.testfile), results)
def _query_id (self, uri):
......
......@@ -3,16 +3,15 @@ import os
import subprocess
import shutil
import tempfile
import configuration as cfg
from gi.repository import GObject
from gi.repository import GLib
import time
import options
from dconf import DConfClient
import helpers
from common.utils import configuration as cfg
from common.utils import options
from common.utils.dconf import DConfClient
from common.utils import helpers
TEST_ENV_VARS = { "LC_COLLATE": "en_GB.utf8" }
......@@ -57,7 +56,7 @@ class TrackerSystemAbstraction (object):
"XDG_CACHE_HOME": self.xdg_cache_home()
}
for var, directory in self._dirs.items():
for var, directory in list(self._dirs.items()):
os.makedirs (directory)
os.makedirs (os.path.join(directory, 'tracker'))
os.environ [var] = directory
......@@ -65,7 +64,7 @@ class TrackerSystemAbstraction (object):
if ontodir:
os.environ ["TRACKER_DB_ONTOLOGIES_DIR"] = ontodir
for var, value in TEST_ENV_VARS.iteritems ():
for var, value in TEST_ENV_VARS.items ():
os.environ [var] = value
# Previous loop should have set DCONF_PROFILE to the test location
......@@ -73,10 +72,10 @@ class TrackerSystemAbstraction (object):
self._apply_settings(settings)
def _apply_settings(self, settings):
for schema_name, contents in settings.iteritems():
for schema_name, contents in settings.items():
dconf = DConfClient(schema_name)
dconf.reset()
for key, value in contents.iteritems():
for key, value in contents.items():
dconf.write(key, value)
def tracker_store_testing_start (self, confdir=None, ontodir=None):
......@@ -173,6 +172,6 @@ class TrackerSystemAbstraction (object):
if self.store:
self.store.stop ()
for path in self._dirs.values():
for path in list(self._dirs.values()):
shutil.rmtree(path)
os.rmdir(self._basedir)
......@@ -25,7 +25,7 @@ import os
import shutil
import re
import time
import commands
import subprocess
TRACKER = 'org.freedesktop.Tracker1'
TRACKER_OBJ = '/org/freedesktop/Tracker1/Resources'
......@@ -43,7 +43,7 @@ class TestInsertion (unittest.TestCase):
try:
os.mkdir (os.getcwd() + "/tmp")
except:
print ""
print("")
shutil.copy2 (os.getcwd() + "/data/test01.jpg",
os.getcwd() + "/tmp/test01.jpg")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment