Esempio n. 1
0
 def check_build_search_order3(self):
     """ If MODULE is absent, module_dir shouldn't be in search path.
     """
     q = catalog.catalog(['first','second'])
     q.set_module_directory('third')
     order = q.build_search_order()
     assert(order == ['first','second',catalog.default_dir()])
Esempio n. 2
0
 def check_build_search_order1(self):
     """ MODULE in search path should be replaced by module_dir.
     """
     q = catalog.catalog(['first','MODULE','third'])
     q.set_module_directory('second')
     order = q.build_search_order()
     assert(order == ['first','second','third',catalog.default_dir()])
Esempio n. 3
0
def empty_temp_dir():
    """Create a sub directory in the temp directory for use in tests"""
    d = catalog.default_dir()
    for i in range(10000):
        new_d = os.path.join(d,tempfile.gettempprefix()[1:-1]+repr(i))
        if not os.path.exists(new_d):
            os.mkdir(new_d)
            break
    return new_d
Esempio n. 4
0
 def check_is_writable(self):
     path = catalog.default_dir()
     name = os.path.join(path,'dummy_catalog')
     test_file = open(name,'w')
     try:
         test_file.write('making sure default location is writable\n')
     finally:
         test_file.close()
         os.remove(name)
Esempio n. 5
0
 def check_build_search_order4(self):
     """ Make sure environment variable is getting used.
     """
     q = catalog.catalog(['first','second'])
     if sys.platform == 'win32': sep = ';'
     else: sep = ':'
     os.environ['PYTHONCOMPILED'] = sep.join(('MODULE','fourth','fifth'))
     q.set_module_directory('third')
     order = q.build_search_order()
     assert(order == ['first','second','third','fourth','fifth',catalog.default_dir()])
Esempio n. 6
0
 def test_is_writable(self):
     # default_dir has to be writable
     path = catalog.default_dir()
     name = os.path.join(path, "dummy_catalog")
     test_file = open(name, "w")
     try:
         test_file.write("making sure default location is writable\n")
     finally:
         test_file.close()
         os.remove(name)
Esempio n. 7
0
 def test_is_writable(self):
     # default_dir has to be writable
     path = catalog.default_dir()
     name = os.path.join(path, 'dummy_catalog')
     test_file = open(name, 'w')
     try:
         test_file.write('making sure default location is writable\n')
     finally:
         test_file.close()
         os.remove(name)
Esempio n. 8
0
 def test_build_search_order4(self):
     # Make sure environment variable is getting used.
     q = catalog.catalog(['first','second'])
     if sys.platform == 'win32':
         sep = ';'
     else:
         sep = ':'
     os.environ['PYTHONCOMPILED'] = sep.join(('MODULE','fourth','fifth'))
     q.set_module_directory('third')
     order = q.build_search_order()
     assert_(order == ['first','second','third','fourth','fifth',catalog.default_dir()])
Esempio n. 9
0
 def test_build_search_order4(self):
     # Make sure environment variable is getting used.
     q = catalog.catalog(["first", "second"])
     if sys.platform == "win32":
         sep = ";"
     else:
         sep = ":"
     os.environ["PYTHONCOMPILED"] = sep.join(("MODULE", "fourth", "fifth"))
     q.set_module_directory("third")
     order = q.build_search_order()
     assert_(order == ["first", "second", "third", "fourth", "fifth", catalog.default_dir()])
Esempio n. 10
0
def restore_temp_catalog(backup_dir):
    """Remove any catalog from the temp dir"""
    cat_dir = catalog.default_dir()
    for file in os.listdir(backup_dir):
        file = os.path.join(backup_dir,file)
        d,f = os.path.split(file)
        dst_file = os.path.join(cat_dir, f)
        if os.path.exists(dst_file):
            os.remove(dst_file)
        move_file(file,dst_file)

    os.rmdir(backup_dir)
Esempio n. 11
0
 def test_build_search_order1(self):
     # MODULE in search path should be replaced by module_dir.
     q = catalog.catalog(['first', 'MODULE', 'third'])
     q.set_module_directory('second')
     order = q.build_search_order()
     assert_(order == ['first', 'second', 'third', catalog.default_dir()])
Esempio n. 12
0
 def test_default(self):
     in_path = catalog.default_dir()
     path = catalog.catalog_path(in_path)
     d, f = os.path.split(path)
     assert_(d == in_path)
     assert_(f == catalog.os_dependent_catalog_name())
Esempio n. 13
0
def temp_catalog_files(prefix=''):
    # might need to add some more platform specific catalog file
    # suffixes to remove.  The .pag was recently added for SunOS
    d = catalog.default_dir()
    f = catalog.os_dependent_catalog_name()
    return glob.glob(os.path.join(d,prefix+f+'*'))
Esempio n. 14
0
 def check_default(self):
     in_path = catalog.default_dir()
     path = catalog.catalog_path(in_path)
     d,f = os.path.split(path)
     assert(d == in_path)
     assert(f == catalog.os_dependent_catalog_name())
Esempio n. 15
0
 def test_build_search_order1(self):
     # MODULE in search path should be replaced by module_dir.
     q = catalog.catalog(["first", "MODULE", "third"])
     q.set_module_directory("second")
     order = q.build_search_order()
     assert_(order == ["first", "second", "third", catalog.default_dir()])
Esempio n. 16
0
 def test_build_search_order2(self):
     # MODULE in search path should be removed if module_dir==None.
     q = catalog.catalog(["first", "MODULE", "third"])
     order = q.build_search_order()
     assert_(order == ["first", "third", catalog.default_dir()])
Esempio n. 17
0
 def check_build_search_order2(self):
     """ MODULE in search path should be removed if module_dir==None.
     """
     q = catalog.catalog(['first','MODULE','third'])
     order = q.build_search_order()
     assert(order == ['first','third',catalog.default_dir()])
Esempio n. 18
0
 def test_build_search_order3(self):
     # If MODULE is absent, module_dir shouldn't be in search path.
     q = catalog.catalog(["first", "second"])
     q.set_module_directory("third")
     order = q.build_search_order()
     assert_(order == ["first", "second", catalog.default_dir()])
Esempio n. 19
0
 def test_build_search_order2(self):
     # MODULE in search path should be removed if module_dir==None.
     q = catalog.catalog(['first', 'MODULE', 'third'])
     order = q.build_search_order()
     assert_(order == ['first', 'third', catalog.default_dir()])
Esempio n. 20
0
 def test_build_search_order3(self):
     # If MODULE is absent, module_dir shouldn't be in search path.
     q = catalog.catalog(['first', 'second'])
     q.set_module_directory('third')
     order = q.build_search_order()
     assert_(order == ['first', 'second', catalog.default_dir()])
Esempio n. 21
0
def temp_catalog_files(prefix=''):
    # might need to add some more platform specific catalog file
    # suffixes to remove.  The .pag was recently added for SunOS
    d = catalog.default_dir()
    f = catalog.os_dependent_catalog_name()
    return glob.glob(os.path.join(d,prefix+f+'*'))