josiahcarlson / redis-in-action

Example code from the book

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why comparing vistor count with a string key in this test?

samluthebrave opened this issue · comments

https://github.com/josiahcarlson/redis-in-action/blob/master/python/ch10_listing_source.py#L655

keys = conn.keys(base + ':*')
for k in keys:
    cnt = conn.scard(k)
    total += cnt
    self.assertTrue(cnt < k)

cnt is an integer while k is a redis key (e.g., "unique:2017-03-30:5423"), why asserting cnt is less than k here?

Sorry, missed this issue the other day when I was going through. There is clearly not any good reason to compare a string to an integer, and I can't ask myself from 4-5 years ago when I was writing this why that line got there. I've deleted the line.

Thank you for the bug report.

Thank you!