blob: 439ce2eb585965b90475a393d2a9ee55869033cc [file] [log] [blame]
Matteo Scandolodb7508e2018-03-19 15:06:06 -07001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import logging
16import os
17
18from nose2.events import Plugin
19
20log = logging.getLogger('nose2.plugins.excludeignoredfiles')
21
22class ExcludeIgnoredFiles(Plugin):
23 commandLineSwitch = (None, 'exclude-ignored-files', 'Exclude that which should be excluded')
24
25 def matchPath(self, event):
26 if event.path.endswith(".py"):
27 text = open(event.path, "r").read()
28 if "test_framework: ignore" in text.lower():
29 log.info("Ignoring %s" % event.path)
30 event.handled = True
31 return False