[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-wget] [GSoC PATCH 10/11] ensure line feed at EOF and one blank line
From: |
Zihang Chen |
Subject: |
[Bug-wget] [GSoC PATCH 10/11] ensure line feed at EOF and one blank line between methods |
Date: |
Fri, 14 Mar 2014 21:18:26 +0800 |
diff --git a/testenv/ChangeLog b/testenv/ChangeLog
index dc6dbb0..e48b636 100644
--- a/testenv/ChangeLog
+++ b/testenv/ChangeLog
@@ -1,4 +1,7 @@
2014-03-14 Zihang Chen <address@hidden>
+ * test, misc, exc, conf: Ensure line feed at EOF, ensure one blank line
+ between methods.
+2014-03-14 Zihang Chen <address@hidden>
* README: Amend README according to previous commits.
2014-03-13 Zihang Chen <address@hidden>
* base_test.py:
diff --git a/testenv/conf/__init__.py b/testenv/conf/__init__.py
index 2b37f79..18bd23a 100644
--- a/testenv/conf/__init__.py
+++ b/testenv/conf/__init__.py
@@ -41,4 +41,4 @@ for module in os.listdir(os.path.dirname(__file__)):
module_name = module[:-3]
mod = __import__('%s.%s' % (__name__, module_name),
globals(),
- locals())
\ No newline at end of file
+ locals())
diff --git a/testenv/conf/authentication.py b/testenv/conf/authentication.py
index 4a944b4..1b73b50 100644
--- a/testenv/conf/authentication.py
+++ b/testenv/conf/authentication.py
@@ -6,4 +6,4 @@ class Authentication:
def __init__ (self, auth_obj):
self.auth_type = auth_obj['Type']
self.auth_user = auth_obj['User']
- self.auth_pass = auth_obj['Pass']
\ No newline at end of file
+ self.auth_pass = auth_obj['Pass']
diff --git a/testenv/conf/expected_files.py b/testenv/conf/expected_files.py
index 2052394..fd41c34 100644
--- a/testenv/conf/expected_files.py
+++ b/testenv/conf/expected_files.py
@@ -10,7 +10,6 @@ class ExpectedFiles:
def __init__(self, expected_fs):
self.expected_fs = expected_fs
-
@staticmethod
def gen_local_fs_snapshot():
snapshot = {}
@@ -24,7 +23,6 @@ class ExpectedFiles:
return snapshot
-
def __call__(self, test_obj):
local_fs = self.gen_local_fs_snapshot()
for file in self.expected_fs:
@@ -41,4 +39,4 @@ class ExpectedFiles:
raise TestFailed('Expected file %s not found.' % file.name)
if local_fs:
print(local_fs)
- raise TestFailed('Extra files downloaded.')
\ No newline at end of file
+ raise TestFailed('Extra files downloaded.')
diff --git a/testenv/conf/expected_ret_code.py
b/testenv/conf/expected_ret_code.py
index bf8b9aa..455cc1c 100644
--- a/testenv/conf/expected_ret_code.py
+++ b/testenv/conf/expected_ret_code.py
@@ -7,11 +7,10 @@ class ExpectedRetCode:
def __init__(self, expected_ret_code):
self.expected_ret_code = expected_ret_code
-
def __call__(self, test_obj):
if test_obj.ret_code != self.expected_ret_code:
failure = "Return codes do not match.\n" \
"Expected: %s\n" \
"Actual: %s" % (self.expected_ret_code,
test_obj.ret_code)
- raise TestFailed(failure)
\ No newline at end of file
+ raise TestFailed(failure)
diff --git a/testenv/conf/files_crawled.py b/testenv/conf/files_crawled.py
index c1362cd..d423086 100644
--- a/testenv/conf/files_crawled.py
+++ b/testenv/conf/files_crawled.py
@@ -8,7 +8,6 @@ class FilesCrawled:
def __init__(self, request_headers):
self.request_headers = request_headers
-
def __call__(self, test_obj):
for headers, remaining in zip(map(set, self.request_headers),
test_obj.request_remaining()):
@@ -16,4 +15,4 @@ class FilesCrawled:
if diff:
print_red(diff)
- raise TestFailed('Not all files were crawled correctly.')
\ No newline at end of file
+ raise TestFailed('Not all files were crawled correctly.')
diff --git a/testenv/conf/hook_sample.py b/testenv/conf/hook_sample.py
index 82abe7e..4f3f313 100644
--- a/testenv/conf/hook_sample.py
+++ b/testenv/conf/hook_sample.py
@@ -9,7 +9,6 @@ class SampleHook:
# do conf initialization here
self.arg = sample_hook_arg
-
def __call__(self, test_obj):
# implement hook here
# if you need the test case instance, refer to test_obj
diff --git a/testenv/conf/local_files.py b/testenv/conf/local_files.py
index d2a5c6d..7bdb869 100644
--- a/testenv/conf/local_files.py
+++ b/testenv/conf/local_files.py
@@ -6,8 +6,7 @@ class LocalFiles:
def __init__(self, local_files):
self.local_files = local_files
-
def __call__(self, _):
for f in self.local_files:
with open(f.name, 'w') as fp:
- fp.write(f.content)
\ No newline at end of file
+ fp.write(f.content)
diff --git a/testenv/conf/server_conf.py b/testenv/conf/server_conf.py
index 19ed632..d373931 100644
--- a/testenv/conf/server_conf.py
+++ b/testenv/conf/server_conf.py
@@ -5,7 +5,6 @@ class ServerConf:
def __init__(self, server_settings):
self.server_settings = server_settings
-
def __call__(self, test_obj):
for server in test_obj.servers:
- server.server_sett(self.server_settings)
\ No newline at end of file
+ server.server_sett(self.server_settings)
diff --git a/testenv/conf/server_files.py b/testenv/conf/server_files.py
index 75c3503..66829b3 100644
--- a/testenv/conf/server_files.py
+++ b/testenv/conf/server_files.py
@@ -6,11 +6,10 @@ class ServerFiles:
def __init__(self, server_files):
self.server_files = server_files
-
def __call__(self, test_obj):
for server, files in zip(test_obj.servers, self.server_files):
rules = {f.name: test_obj.get_server_rules(f)
for f in files}
files = {f.name: test_obj._replace_substring(f.content)
for f in files}
- server.server_conf(files, rules)
\ No newline at end of file
+ server.server_conf(files, rules)
diff --git a/testenv/conf/urls.py b/testenv/conf/urls.py
index 12216d2..10bd930 100644
--- a/testenv/conf/urls.py
+++ b/testenv/conf/urls.py
@@ -6,6 +6,5 @@ class URLs:
def __init__(self, urls):
self.urls = urls
-
def __call__(self, test_obj):
- test_obj.urls = self.urls
\ No newline at end of file
+ test_obj.urls = self.urls
diff --git a/testenv/conf/wget_commands.py b/testenv/conf/wget_commands.py
index 2a8583d..5db1808 100644
--- a/testenv/conf/wget_commands.py
+++ b/testenv/conf/wget_commands.py
@@ -6,6 +6,5 @@ class WgetCommands:
def __init__(self, commands):
self.commands = commands
-
def __call__(self, test_obj):
- test_obj.wget_options = test_obj._replace_substring(self.commands)
\ No newline at end of file
+ test_obj.wget_options = test_obj._replace_substring(self.commands)
diff --git a/testenv/exc/test_failed.py b/testenv/exc/test_failed.py
index 3829f6a..de5e02a 100644
--- a/testenv/exc/test_failed.py
+++ b/testenv/exc/test_failed.py
@@ -4,4 +4,4 @@ class TestFailed(Exception):
""" A Custom Exception raised by the Test Environment. """
def __init__ (self, error):
- self.error = error
\ No newline at end of file
+ self.error = error
diff --git a/testenv/misc/colour_terminal.py b/testenv/misc/colour_terminal.py
index a34277c..70385f4 100644
--- a/testenv/misc/colour_terminal.py
+++ b/testenv/misc/colour_terminal.py
@@ -27,5 +27,3 @@ print_red = partial(printer, 'RED')
print_green = partial(printer, 'GREEN')
print_purple = partial(printer, 'PURPLE')
print_yellow = partial(printer, 'YELLOW')
-
-# vim: set ts=8 sw=3 tw=0 et :
\ No newline at end of file
diff --git a/testenv/misc/constants.py b/testenv/misc/constants.py
index 5fad2f8..b74f921 100644
--- a/testenv/misc/constants.py
+++ b/testenv/misc/constants.py
@@ -1,3 +1,3 @@
HTTP = "HTTP"
-HTTPS = "HTTPS"
\ No newline at end of file
+HTTPS = "HTTPS"
diff --git a/testenv/misc/wget_file.py b/testenv/misc/wget_file.py
index 63fc04d..027dced 100644
--- a/testenv/misc/wget_file.py
+++ b/testenv/misc/wget_file.py
@@ -13,4 +13,4 @@ class WgetFile:
self.name = name
self.content = content
self.timestamp = timestamp
- self.rules = rules or {}
\ No newline at end of file
+ self.rules = rules or {}
diff --git a/testenv/test/base_test.py b/testenv/test/base_test.py
index 303de79..d01ef81 100644
--- a/testenv/test/base_test.py
+++ b/testenv/test/base_test.py
@@ -44,11 +44,9 @@ class BaseTest:
self.ret_code = 0
-
def get_test_dir(self):
return self.name + '-test'
-
def init_test_env(self):
test_dir = self.get_test_dir()
try:
@@ -65,7 +63,6 @@ class BaseTest:
return '%s:%s' % (addr[0], self.port)
-
def server_setup(self):
print_blue("Running Test %s" % self.name)
for protocol in self.protocols:
@@ -78,7 +75,6 @@ class BaseTest:
domain = self.get_domain_addr(instance.server_address)
self.domains.append(domain)
-
def exec_wget(self):
cmd_line = self.gen_cmd_line()
params = shlex.split(cmd_line)
@@ -95,7 +91,6 @@ class BaseTest:
return ret_code
-
def gen_cmd_line(self):
test_path = os.path.abspath(".")
wget_path = os.path.abspath(os.path.join(test_path,
@@ -121,7 +116,6 @@ class BaseTest:
return cmd_line
-
def __test_cleanup(self):
os.chdir('..')
try:
@@ -130,15 +124,12 @@ class BaseTest:
except:
print ("Unknown Exception while trying to remove Test
Environment.")
-
def _exit_test (self):
self.__test_cleanup()
-
def begin (self):
return 0 if self.tests_passed else 100
-
def call_test(self):
self.hook_call(self.test_params, 'Test Option')
@@ -149,13 +140,11 @@ class BaseTest:
finally:
self.stop_server()
-
def do_test(self):
self.pre_hook_call()
self.call_test()
self.post_hook_call()
-
def hook_call(self, configs, name):
for conf_name, conf_arg in configs.items():
try:
@@ -169,15 +158,12 @@ class BaseTest:
raise TestFailed("%s %s not defined." %
(name, conf_name))
-
def pre_hook_call(self):
self.hook_call(self.pre_configs, 'Pre Test Function')
-
def post_hook_call(self):
self.hook_call(self.post_configs, 'Post Test Function')
-
def _replace_substring (self, string):
pattern = re.compile ('\{\{\w+\}\}')
match_obj = pattern.search (string)
@@ -187,7 +173,6 @@ class BaseTest:
string = string.replace (rep, temp)
return string
-
def instantiate_server_by(self, protocol):
"""
Subclasses must override this method to actually instantiate servers
@@ -195,7 +180,6 @@ class BaseTest:
"""
raise NotImplementedError
-
def stop_server(self):
"""
Subclasses must implement this method in order to stop certain
@@ -203,7 +187,6 @@ class BaseTest:
"""
raise NotImplementedError
-
@staticmethod
def get_server_rules(file_obj):
"""
@@ -216,14 +199,12 @@ class BaseTest:
server_rules[rule_name] = conf.find_conf(rule_name)(rule)
return server_rules
-
def __enter__(self):
"""
Initialization for with statement.
"""
return self
-
def __exit__(self, exc_type, exc_val, exc_tb):
"""
If the with statement got executed with no exception raised, then
@@ -239,4 +220,4 @@ class BaseTest:
traceback.print_tb(exc_tb)
self.__test_cleanup()
- return True
\ No newline at end of file
+ return True
diff --git a/testenv/test/http_test.py b/testenv/test/http_test.py
index 80ac0a8..37552d6 100644
--- a/testenv/test/http_test.py
+++ b/testenv/test/http_test.py
@@ -29,7 +29,6 @@ class HTTPTest(BaseTest):
self.do_test()
print_green('Test Passed.')
-
def instantiate_server_by(self, protocol):
server = {HTTP: HTTPd,
HTTPS: HTTPSd}[protocol]()
@@ -37,16 +36,10 @@ class HTTPTest(BaseTest):
return server
-
def request_remaining(self):
return [s.server_inst.get_req_headers()
for s in self.servers]
-
def stop_server(self):
for server in self.servers:
server.server_inst.shutdown()
-
-
-
-# vim: set ts=4 sts=4 sw=4 tw=80 et :
\ No newline at end of file
--
1.8.3.2
- [Bug-wget] [GSoC PATCH 00/11] Refactor Test Suite, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 01/11] create package misc, move ColourTerm.py to misc, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 02/11] from WgetTest.py move WgetFile to misc, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 03/11] fix a typo in Test-Proto.py, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 04/11] create package exc and move TestFailed to exc, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 05/11] create package conf where rules and hooks are put, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 06/11] move server classes to package server.protocol, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 07/11] create package test for test case classes, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 08/11] refactor a lot, see ChangeLog for detail, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 09/11] update README, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 10/11] ensure line feed at EOF and one blank line between methods,
Zihang Chen <=
- [Bug-wget] [GSoC PATCH 11/11] in conf, rename register to rule and hook, Zihang Chen, 2014/03/14