'Verify that if a stale .pyc file on the PYTHONPATH is replaced by a
fresh .py file, the plugins in the new .py are picked up rather than
the stale .pyc, even if the .pyc is still around.'

def test_freshPyReplacesStalePyc(self):

    mypath = self.appPackage.child('stale.py')
    mypath.setContent(pluginFileContents('one'))
    x = (time.time() - 1000)
    os.utime(mypath.path, (x, x))
    pyc = mypath.sibling('stale.pyc')
    if _PY3:
        extra = dict(legacy=True)
    else:
        extra = dict()
    compileall.compile_dir(self.appPackage.path, quiet=1, **extra)
    os.utime(pyc.path, (x, x))
    mypath.remove()
    self.resetEnvironment()
    self.assertIn('one', self.getAllPlugins())
    self.failIfIn('two', self.getAllPlugins())
    self.resetEnvironment()
    mypath.setContent(pluginFileContents('two'))
    self.failIfIn('one', self.getAllPlugins())
    self.assertIn('two', self.getAllPlugins())
