yolothreat / utilitybelt

A Python library for being a CND Batman....
MIT License
35 stars 12 forks source link

skips tests that require an API key if that key is not in os.environ #59

Closed blackfist closed 9 years ago

blackfist commented 9 years ago

WARNING this PR will modify some of the tests so you'll want to check it extra carefully.

Some of the tests will fail if they are run on a system where the environment variables are not set. This change to the tests.py file will skip tests that depend on VT_API or URLVOID_API if those environment variables are not set.

blackfist commented 9 years ago

Fixed that @krmaxwell

sroberts commented 9 years ago

Ugh... you lost the merge race with @krmaxwell. Looks like conflict time!

blackfist commented 9 years ago

I blame @krmaxwell.

sroberts commented 9 years ago

@blackfist valid.

krmaxwell commented 9 years ago

Also, out of curiosity, why does the call to os.getenv() specify a default True instead of None? Does that break something?

krmaxwell commented 9 years ago

Also, I fixed the merge conflict in our copy of your branch, no worries.

blackfist commented 9 years ago

I originally had os.getenv("VT_API", False)==False which I realized evaluates to True so I thought why not just get rid of the check for False and just put a true in there instead.

blackfist commented 9 years ago

Further testing on my end seems to show that making the change results in the tests being skipped every time because when the environment variable is set then os.getenv returns a value which is True in python. So here is another fix.

krmaxwell commented 9 years ago

The problem right now is that it looks to me as though it will always skip the test.

unittest.skipIf(condition, reason) Skip the decorated test if condition is true.

os.getenv(varname[, value]) Return the value of the environment variable varname if it exists, or value if it doesn’t. value defaults to None.

Because of this with the default, os.getenv() always returns either an actual value or True, and in that case the @unittest.skipIf() will always trigger.

blackfist commented 9 years ago

That's what I get for trying to be fancy

krmaxwell commented 9 years ago

we already know