1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
10 class FileVerifier(verifier
.Verifier
):
11 """Verifies that the current files match the expectation dictionaries."""
13 def _VerifyExpectation(self
, expectation_name
, expectation
,
15 """Overridden from verifier.Verifier.
17 This method will throw an AssertionError if file state doesn't match the
21 expectation_name: Path to the file being verified. It is expanded using
23 expectation: A dictionary with the following key and value:
24 'exists' a boolean indicating whether the file should exist.
25 variable_expander: A VariableExpander object.
27 file_path
= variable_expander
.Expand(expectation_name
)
28 file_exists
= os
.path
.exists(file_path
)
29 assert expectation
['exists'] == file_exists
, \
30 ('File %s exists' % file_path
) if file_exists
else \
31 ('File %s is missing' % file_path
)