agroce/tstl

AttributeError: 'module' object has no attribute '__file__'

jwilk opened this issue · 4 comments

jwilk commented

It wanted to give TSTL a try, but it doesn't work for me on the nutshell example:

$ tstl tstl/examples/nutshell/nutshell.tstl 
Generating harness core using config=Config(tstl='tstl/examples/nutshell/nutshell.tstl', stats=False, checkFailureDeterminism=False, pylib=False, defaultReplay=False, forceRefExceptionMatch=False, enumerateEnabled=False, forceStrongRefExceptionMatch=False, classname='sut', version=False, noCover=False, debug=False, output='sut.py', noReload=False, ignoreAngles=False, coverReload=False, coverInit=False)

$ tstl_rt
Random testing using config=Config(noExceptionMatch=False, generalize=False, localize=False, speed='FAST', probs=None, LOCBaseline=0.2, noAlphaConvert=False, markovP=1.0, essentials=False, noCoverageExploit=False, quickTests=False, html=None, noReassign=False, stopWhenNoCoverage=None, generateLOC=None, processDetDelay=0, computeFeatureStats=False, stopTestWhenNoCoverage=None, Pmutate=0.0, timeout=3600, output='failure.1658.test', markov=None, noSwarmDependencies=False, startExploit=0.0, maxMustHitBranch=None, useHints=False, silentFail=False, highLowSwarm=None, maxMustHitStatement=None, equalProbs=False, progress=False, postCover=False, swarmLength=None, processDetTries=1, noCover=False, noEnumerateEnabled=False, full=False, swarmP=0.5, coverFile='coverage.out', replayable=False, swarmProbs=None, genDepth=None, exploitCeiling=0.5, logging=None, noCheck=False, throughput=False, uncaught=False, swarmSwitch=None, verbose=False, reducePool=False, exploit=None, fastQuickAnalysis=False, determinismTries=1, total=False, verboseExploit=False, swarm=False, sequenceP=1.0, biasLOC=None, timedProgress=30, relax=False, ddmin=False, stutter=None, readQuick=False, verboseActions=False, quickAnalysis=False, keepLast=False, sequenceSize=3, LOCProbs=False, sequencesFromTests=None, hideOpaque=False, maxTests=-1, trackMaxCoverage=None, useQuickSequences=False, exploitBestHint=1, failedLogging=None, stopWhenStatements=None, greedyStutter=False, seed=None, stopWhenHitStatement=None, checkDeterminism=False, uniqueValuesAnalysis=False, normalize=False, startExploitStall=0, enumerateEnabled=False, stopTestWhenThroughputBelow=None, internal=False, profile=False, multiple=False, stopWhenBranches=None, running=False, compareFails=False, Pcrossover=0.2, stopWhenHitBranch=None, checkProcessDeterminism=False, depth=100, localizeTop=20, showActions=False)
Traceback (most recent call last):
  File "/home/jwilk/.local/bin/tstl_rt", line 11, in <module>
    load_entry_point('tstl==1.2.12', 'console_scripts', 'tstl_rt')()
  File "/home/jwilk/.local/lib/python2.7/site-packages/src/randomtester.py", line 729, in main
    sut = SUT.sut()
  File "/home/jwilk/sut.py", line 6156, in __init__
    self.__cov = coverage.coverage(branch=True, source=self.moduleLocations(),    omit='sut.py'    )
  File "/home/jwilk/sut.py", line 9918, in moduleLocations
    f = m.__file__
AttributeError: 'module' object has no attribute '__file__'

Apparently it trips over the math module, which indeed doesn't have the __file__ attribute.

Tested with git master (1dfa1ee).

Weird. Works for me on master, in both 2.7 and 3.6. On Mac OS, looks like math DOES have a file. Let me add code to handle imports with neither (which are going to be system libraries we don't want to trace coverage for, anyway).

Ok, grab last push and see if it fixes this (I can't test locally, without spinning up a VM)

(odd that the pyfakefs team never stumbled across this, I think they used on both windows and linux; what Python / OS are you on?)

jwilk commented

c45f69c fixes it for me. Thanks.

This is Python 2.7.15rc1 on Debian unstable.