def test_Universe_invalidfile_IE_msg(): # check for invalid file (something with the wrong content) temp_dir = TempDir() with open(os.path.join(temp_dir.name, 'invalid.file.tpr'), 'w') as temp_file: temp_file.write('plop') try: mda.Universe(os.path.join(temp_dir.name, 'invalid.file.tpr')) except IOError as e: assert_('file or cannot be recognized' in e.args[0]) else: raise AssertionError finally: temp_dir.dissolve()
def test_Universe_invalidfile_IE_msg(self): # check for invalid file (something with the wrong content) temp_dir = TempDir() with open(os.path.join(temp_dir.name, 'invalid.file.tpr'), 'w') as temp_file: temp_file.write('plop') try: mda.Universe(os.path.join(temp_dir.name, 'invalid.file.tpr')) except IOError as e: assert 'file or cannot be recognized' in e.args[0] else: raise AssertionError finally: temp_dir.dissolve()
def test_Universe_invalidpermissionfile_IE_msg(): # check for file with invalid permissions (eg. no read access) temp_dir = TempDir() temp_file = os.path.join(temp_dir.name, 'permission.denied.tpr') with open(temp_file, 'w'): pass os.chmod(temp_file, 0o200) try: mda.Universe(os.path.join(temp_dir.name, 'permission.denied.tpr')) except IOError as e: assert_('Permission denied' in e.strerror) else: raise AssertionError finally: temp_dir.dissolve()
def test_Universe_invalidpermissionfile_IE_msg(self): # check for file with invalid permissions (eg. no read access) temp_dir = TempDir() temp_file = os.path.join(temp_dir.name, 'permission.denied.tpr') with open(temp_file, 'w'): pass if os.name == 'nt': subprocess.call("icacls {filename} /deny Users:RX".format(filename=temp_file), shell=True) else: os.chmod(temp_file, 0o200) try: mda.Universe(os.path.join(temp_dir.name, 'permission.denied.tpr')) except IOError as e: assert 'Permission denied' in str(e.strerror) else: raise AssertionError finally: temp_dir.dissolve()
def test_Universe_invalidpermissionfile_IE_msg(self): # check for file with invalid permissions (eg. no read access) temp_dir = TempDir() temp_file = os.path.join(temp_dir.name, 'permission.denied.tpr') with open(temp_file, 'w'): pass if os.name == 'nt': subprocess.call( "icacls {filename} /deny Users:RX".format(filename=temp_file), shell=True) else: os.chmod(temp_file, 0o200) try: mda.Universe(os.path.join(temp_dir.name, 'permission.denied.tpr')) except IOError as e: assert 'Permission denied' in str(e.strerror) else: raise AssertionError finally: temp_dir.dissolve()