You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.0 KiB

import os
import sys
import unittest
import tempfile
from ssh_config_utils.parser import CamelCase_to_snake
samples_dir = os.path.join(sys.path[0], "sample_configs")
CONFIG_FILES = dict(
(file, os.path.join(samples_dir, file)) for file in os.listdir(samples_dir)
)
class ReadWriteTest(unittest.TestCase):
def setUp(self):
self.write_file = tempfile.TemporaryFile(mode="r+")
def tearDown(self):
self.write_file.close()
class TestTempFile(ReadWriteTest):
def test_me(self):
self.write_file.write("hello")
self.write_file.seek(0)
self.assertEqual(self.write_file.read(), "hello")
class TestParser(ReadWriteTest):
def test_camel_case_to_snake_case(self):
initial_vals = "ThisIsCamelCase", "This"
expected_vals = "this_is_camel_case", "this"
for initial, expected in zip(initial_vals, expected_vals):
with self.subTest(initial=initial, expected=expected):
self.assertEqual(CamelCase_to_snake(initial), expected)