示例#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()])
示例#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()])
示例#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
示例#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)
示例#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()])
示例#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)
示例#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)
示例#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()])
示例#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()])
示例#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)
示例#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()])
示例#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())
示例#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+'*'))
示例#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())
示例#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()])
示例#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()])
示例#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()])
示例#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()])
示例#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()])
示例#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()])
示例#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+'*'))