mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Merge pull request #122941 from bart0sh/PR130-cleanup-boilerplate_test
Fix and cleanup boilerplate_test.py
This commit is contained in:
commit
d3479eeeac
@ -14,39 +14,40 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import boilerplate
|
|
||||||
import unittest
|
|
||||||
from io import StringIO
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from io import StringIO
|
||||||
|
|
||||||
|
import boilerplate
|
||||||
|
|
||||||
class TestBoilerplate(unittest.TestCase):
|
class TestBoilerplate(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
Note: run this test from the hack/boilerplate directory.
|
Note: run this test from the hack/boilerplate directory.
|
||||||
|
|
||||||
$ python -m unittest boilerplate_test
|
$ python -m unittest boilerplate_test
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def test_boilerplate(self):
|
def test_boilerplate(self):
|
||||||
os.chdir("test/")
|
os.chdir("test/")
|
||||||
|
|
||||||
class Args(object):
|
class Args:
|
||||||
def __init__(self):
|
filenames = []
|
||||||
self.filenames = []
|
rootdir = "."
|
||||||
self.rootdir = "."
|
boilerplate_dir = "../"
|
||||||
self.boilerplate_dir = "../"
|
verbose = True
|
||||||
self.verbose = True
|
|
||||||
|
|
||||||
# capture stdout
|
# capture stdout
|
||||||
old_stdout = sys.stdout
|
old_stdout = sys.stdout
|
||||||
sys.stdout = StringIO.StringIO()
|
sys.stdout = StringIO()
|
||||||
|
|
||||||
boilerplate.args = Args()
|
boilerplate.args = Args
|
||||||
ret = boilerplate.main()
|
ret = boilerplate.main()
|
||||||
|
self.assertEqual(ret, 0)
|
||||||
|
|
||||||
output = sorted(sys.stdout.getvalue().split())
|
output = sorted(sys.stdout.getvalue().split())
|
||||||
|
|
||||||
sys.stdout = old_stdout
|
sys.stdout = old_stdout
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(output, ["././fail.go", "././fail.py"])
|
||||||
output, ['././fail.go', '././fail.py'])
|
|
||||||
|
Loading…
Reference in New Issue
Block a user