

@pytest.mark.parametrize('rebuild_with_force', [False, True])
def dependency_refresh_with_cache(self, rebuild_with_force):
    "If a bundle dependency is changed, the cache may not be\n        used; otherwise, we'd be using previous build results from\n        the cache, where we really need to do a refresh, because,\n        for example, an included file has changed.\n        "
    DEPENDENCY = 'dependency.sass'
    DEPENDENCY_SUB = 'dependency_sub.sass'
    self.env.updater = TimestampUpdater()
    self.env.cache = MemoryCache(100)
    self.create_files({
        DEPENDENCY: '-main',
        DEPENDENCY_SUB: '-sub',
        'in': '',
        'in_sub': '',
    })
    bundle = self.mkbundle('in', output='out', depends=(DEPENDENCY,), filters=(lambda in_, out: out.write((in_.read() + self.get(DEPENDENCY)))))
    bundle.contents += (self.mkbundle('in_sub', filters=(lambda in_, out: out.write(self.get(DEPENDENCY_SUB)))),)
    bundle.build()
    assert (self.get('out') == '\n-sub-main')
    assert self.env.cache.keys
    self.create_files({
        DEPENDENCY: '-main12345',
    })
    self.create_files({
        DEPENDENCY_SUB: '-subABCDE',
    })
    now = self.setmtime('out')
    self.setmtime('in', 'in_sub', mtime=(now - 100))
    self.setmtime(DEPENDENCY, DEPENDENCY_SUB, mtime=(now + 100))
    bundle.build(force=rebuild_with_force)
    if rebuild_with_force:
        assert (self.get('out') == '\n-sub-main12345')
    else:
        assert (self.get('out') == '\n-subABCDE-main12345')

dataset/ETHPy150Open miracle2k/webassets/tests/test_bundle_build.py TestAutoBuild.dependency_refresh_with_cache/original