log2d icon indicating copy to clipboard operation
log2d copied to clipboard

.find by level broken

Open PFython opened this issue 2 years ago • 1 comments

I think this is my fault - many apologies Mike!

When refactoring the variable names I must've broken the level= logic, such that the following test (which I've added to test_log2d.py) doesn't work but should!:

@create_mylog
def test_find_levels():
    Log.mylog.info("Oneline")
    assert mylog.find(level="error") == []
    assert mylog.find(level="ERRor") == []
    assert len(mylog.find(level="info")) == 1
    assert len(mylog.find(level="InFo")) == 1

This test is also failing for the same reason:

def test_find_by_level():
    create_dummy_log()
    mylog.logger.error(f"Message: Yet another last line")
    result = mylog.find(text="error")
    assert "ERROR" in result[0], f"FIND5: ERROR message not found"
    result = mylog.find(text="error", ignorecase=False)
    assert not result
    result = mylog.find(level="error")
    assert len(result) == 6, f"FIND6: Expected 6 records, found {len(result)}"
    cleanup()

I'm hoping you can spot where I've gone wrong and put it right using PEP8/snake_case variable names please?

I owe you!

PFython avatar Dec 14 '22 22:12 PFython

Fixed in pull request #17

MikeDP avatar Mar 28 '23 14:03 MikeDP