def test_pretend_create_directory(tmpfolder, caplog): # When a directory is created with pretend=True, utils.create_directory('a-dir', pretend=True) # Then it should not appear in the disk, assert tmpfolder.join('a-dir').check() is False # But the operation should be logged for text in ('create', 'a-dir'): assert text in last_log(caplog)
def test_pretend_create_directory(tmpfolder, caplog): caplog.set_level(logging.INFO) # When a directory is created with pretend=True, utils.create_directory('a-dir', pretend=True) # Then it should not appear in the disk, assert tmpfolder.join('a-dir').check() is False # But the operation should be logged for text in ('create', 'a-dir'): assert text in last_log(caplog)
def test_pretend_create_directory(tmpfolder, caplog): caplog.set_level(logging.INFO) dname = uniqstr() # Use a unique name to get easily identifiable logs # When a directory is created with pretend=True, utils.create_directory(dname, pretend=True) # Then it should not appear in the disk, assert tmpfolder.join(dname).check() is False # But the operation should be logged logs = caplog.text assert re.search("create.+" + dname, logs)
def test_update_directory(tmpfolder, caplog): # When a directory exists, tmpfolder.join('a-dir').ensure_dir() # And it is created again, with pytest.raises(OSError): # Then an error should be raised, utils.create_directory('a-dir') clear_log(caplog) # But when it is created again with the update flag, utils.create_directory('a-dir', update=True) # Then no exception should be raised, # But no log should be produced also. assert len(caplog.records) == 0
def test_update_directory(tmpfolder, caplog): caplog.set_level(logging.INFO) dname = uniqstr() # Use a unique name to get easily identifiable logs # When a directory exists, tmpfolder.join(dname).ensure_dir() # And it is created again, with pytest.raises(OSError): # Then an error should be raised, utils.create_directory(dname) # But when it is created again with the update flag, utils.create_directory(dname, update=True) # Then no exception should be raised, # But no log should be produced also. logs = caplog.text assert not re.search("create.+" + dname, logs)
def test_update_directory(tmpfolder, caplog): caplog.set_level(logging.INFO) # When a directory exists, tmpfolder.join('a-dir').ensure_dir() # And it is created again, with pytest.raises(OSError): # Then an error should be raised, utils.create_directory('a-dir') clear_log(caplog) # But when it is created again with the update flag, utils.create_directory('a-dir', update=True) # Then no exception should be raised, # But no log should be produced also. assert len(caplog.records) == 0
def test_create_directory(tmpfolder): utils.create_directory("a-dir", "content") assert tmpfolder.join("a-dir").check(dir=1)
def test_create_directory(tmpfolder): utils.create_directory('a-dir', 'content') assert tmpfolder.join('a-dir').check(dir=1)