Hi Anto, all, First of all, please keep asking "usage" questions or ask for examples for practical / real life problems you have. They help me filling the example sections of the new py.test docs with useful material :)
On Sat, Oct 16, 2010 at 19:05 +0200, Antonio Cuni wrote: > I need a way to distinguish whether the current module is being imported > because we are running the tests, of whether we are running the main program. > > I know that the correct way would be to inject the information from the top, > but I'm using a framework which relies on some global state to store the > various options, and I have to deal with it. Right, which is why i wouldn't like this to be totally convenient :) > Anyway, is there any official/recommended way to do it? > What I'm doing right now is this (py 1.3.1): > > if py.test.config.__dict__ == {}: > # py.test is NOT running > ... > else: > # py.test is running uh, hacky :) also will break with pytest-2.0 as the py.test.config will not be there outside of test runs. I drafted an example which should also work with py-1.3.1 as part of the examples section of the upcoming pytest docs: http://codespeak.net/~hpk/pytest/example/misc.html Works for you? cheers, holger _______________________________________________ py-dev mailing list py-dev@codespeak.net http://codespeak.net/mailman/listinfo/py-dev