[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-wget] [GSoC PATCH 11/11] in conf, rename register to rule and h
From: |
Zihang Chen |
Subject: |
Re: [Bug-wget] [GSoC PATCH 11/11] in conf, rename register to rule and hook |
Date: |
Fri, 14 Mar 2014 21:28:58 +0800 |
So sorry I flooded the mailing list. I thought --chain-reply-to is turned
on by default :(
2014-03-14 21:18 GMT+08:00 Zihang Chen <address@hidden>:
>
> diff --git a/testenv/ChangeLog b/testenv/ChangeLog
> index e48b636..879d765 100644
> --- a/testenv/ChangeLog
> +++ b/testenv/ChangeLog
> @@ -1,4 +1,14 @@
> 2014-03-14 Zihang Chen <address@hidden>
> + * conf:
> + (__init__.py): Enforce that _register and gen_hook are not
> exported. Add
> + rule and hook to decorate respective
> classes.
> + (authentication.py, expect_header.py, reject_header.py,
> response.py,
> + rule_sample.py, send_header.py): Change register to rule.
> + (expected_files.py, expected_ret_code.py, files_crawled.py,
> + hook_sample.py, local_files.py, server_conf.py, server_files.py,
> urls.py,
> + wget_commands.py): Change register to hook.
> + * README: Update readme according to the changes in package conf.
> +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>
> diff --git a/testenv/README b/testenv/README
> index 56df646..fdf948c 100644
> --- a/testenv/README
> +++ b/testenv/README
> @@ -235,20 +235,39 @@ file name doesn't matters (though it's better to
> give it an appropriate name).
> The new rule class should be like this:
>
> =============================================================
> -from conf import register
> +from conf import rule
>
>
> address@hidden()
> address@hidden()
> class MyNewRule:
>
> def __init__(self, rule_arg):
> self.rule_arg = rule_arg
> # your rule initialization code goes here
> =============================================================
> -
> Additionally, A method with the exact name of the newly created rule
> class must
> also be defined in HTTPTest / FTPTest modules to handle the said Rule.
>
> +If you need new hooks, you can implement a new class in the conf package.
> The
> +file name too doesn't matters. The new hook class should be like this:
> +
> +=============================================================
> +from conf import hook
> +
> +
> address@hidden()
> +class MyNewHook:
> +
> + def __init__(self, hook_arg):
> + self.hook_arg = hook_arg
> + # your hook initialization code goes here
> +
> + def __call__(self, test_obj):
> + # test_obj is a reference to the caller test case object
> + # your actual hook code goes here
> +=============================================================
> +
> +
> Once a new Test File is created, it must be added to the TESTS variable in
> Makefile.am. This way the Test will be executed on running a 'make check'.
> If a Test is expected to fail on the current master branch, then the Test
> should
> diff --git a/testenv/conf/__init__.py b/testenv/conf/__init__.py
> index 18bd23a..0a7eb41 100644
> --- a/testenv/conf/__init__.py
> +++ b/testenv/conf/__init__.py
> @@ -31,7 +31,11 @@ def gen_hook():
>
> return Wrapper, find_hook
>
> -register, find_conf = gen_hook()
> +_register, find_conf = gen_hook()
> +
> +rule = hook = _register
> +
> +__all__ = ['rule', 'hook']
>
> for module in os.listdir(os.path.dirname(__file__)):
> # import every module under this package except __init__.py,
> @@ -42,3 +46,4 @@ for module in os.listdir(os.path.dirname(__file__)):
> mod = __import__('%s.%s' % (__name__, module_name),
> globals(),
> locals())
> + __all__.append(module_name)
> diff --git a/testenv/conf/authentication.py
> b/testenv/conf/authentication.py
> index 1b73b50..58cbaff 100644
> --- a/testenv/conf/authentication.py
> +++ b/testenv/conf/authentication.py
> @@ -1,7 +1,7 @@
> -from conf import register
> +from conf import rule
>
>
> address@hidden()
> address@hidden()
> class Authentication:
> def __init__ (self, auth_obj):
> self.auth_type = auth_obj['Type']
> diff --git a/testenv/conf/expect_header.py b/testenv/conf/expect_header.py
> index ef4eee3..87b0e24 100644
> --- a/testenv/conf/expect_header.py
> +++ b/testenv/conf/expect_header.py
> @@ -1,7 +1,7 @@
> -from conf import register
> +from conf import rule
>
>
> address@hidden()
> address@hidden()
> class ExpectHeader:
> def __init__(self, header_obj):
> self.headers = header_obj
> diff --git a/testenv/conf/expected_files.py
> b/testenv/conf/expected_files.py
> index fd41c34..a8b2ee1 100644
> --- a/testenv/conf/expected_files.py
> +++ b/testenv/conf/expected_files.py
> @@ -1,11 +1,11 @@
> from difflib import unified_diff
> import os
> import sys
> -from conf import register
> +from conf import hook
> from exc.test_failed import TestFailed
>
>
> address@hidden()
> address@hidden()
> class ExpectedFiles:
> def __init__(self, expected_fs):
> self.expected_fs = expected_fs
> diff --git a/testenv/conf/expected_ret_code.py
> b/testenv/conf/expected_ret_code.py
> index 455cc1c..5f53f8c 100644
> --- a/testenv/conf/expected_ret_code.py
> +++ b/testenv/conf/expected_ret_code.py
> @@ -1,8 +1,8 @@
> from exc.test_failed import TestFailed
> -from conf import register
> +from conf import hook
>
>
> address@hidden(alias='ExpectedRetcode')
> address@hidden(alias='ExpectedRetcode')
> class ExpectedRetCode:
> def __init__(self, expected_ret_code):
> self.expected_ret_code = expected_ret_code
> diff --git a/testenv/conf/files_crawled.py b/testenv/conf/files_crawled.py
> index d423086..ad6d0f1 100644
> --- a/testenv/conf/files_crawled.py
> +++ b/testenv/conf/files_crawled.py
> @@ -1,9 +1,9 @@
> from misc.colour_terminal import print_red
> -from conf import register
> +from conf import hook
> from exc.test_failed import TestFailed
>
>
> address@hidden()
> address@hidden()
> class FilesCrawled:
> def __init__(self, request_headers):
> self.request_headers = request_headers
> diff --git a/testenv/conf/hook_sample.py b/testenv/conf/hook_sample.py
> index 4f3f313..8d4de4c 100644
> --- a/testenv/conf/hook_sample.py
> +++ b/testenv/conf/hook_sample.py
> @@ -1,9 +1,9 @@
> from exc.test_failed import TestFailed
> -from conf import register
> +from conf import hook
>
> # this file is a hook example
>
> address@hidden(alias='SampleAlias')
> address@hidden(alias='SampleAlias')
> class SampleHook:
> def __init__(self, sample_hook_arg):
> # do conf initialization here
> diff --git a/testenv/conf/local_files.py b/testenv/conf/local_files.py
> index 7bdb869..1eb3e4e 100644
> --- a/testenv/conf/local_files.py
> +++ b/testenv/conf/local_files.py
> @@ -1,7 +1,7 @@
> -from conf import register
> +from conf import hook
>
>
> address@hidden()
> address@hidden()
> class LocalFiles:
> def __init__(self, local_files):
> self.local_files = local_files
> diff --git a/testenv/conf/reject_header.py b/testenv/conf/reject_header.py
> index 81c76c4..1f45145 100644
> --- a/testenv/conf/reject_header.py
> +++ b/testenv/conf/reject_header.py
> @@ -1,7 +1,7 @@
> -from conf import register
> +from conf import rule
>
>
> address@hidden()
> address@hidden()
> class RejectHeader:
> def __init__ (self, header_obj):
> self.headers = header_obj
> diff --git a/testenv/conf/response.py b/testenv/conf/response.py
> index 32a639a..23d55de 100644
> --- a/testenv/conf/response.py
> +++ b/testenv/conf/response.py
> @@ -1,7 +1,7 @@
> -from conf import register
> +from conf import rule
>
>
> address@hidden()
> address@hidden()
> class Response:
> def __init__(self, ret_code):
> self.response_code = ret_code
> diff --git a/testenv/conf/rule_sample.py b/testenv/conf/rule_sample.py
> index 6544af1..6345a3c 100644
> --- a/testenv/conf/rule_sample.py
> +++ b/testenv/conf/rule_sample.py
> @@ -1,7 +1,7 @@
> -from conf import register
> +from conf import rule
>
>
> address@hidden(alias='SampleRuleAlias')
> address@hidden(alias='SampleRuleAlias')
> class SampleRule:
> def __init__(self, rule):
> # do rule initialization here
> diff --git a/testenv/conf/send_header.py b/testenv/conf/send_header.py
> index 6ef20fd..61dbc0e 100644
> --- a/testenv/conf/send_header.py
> +++ b/testenv/conf/send_header.py
> @@ -1,7 +1,7 @@
> -from conf import register
> +from conf import rule
>
>
> address@hidden()
> address@hidden()
> class SendHeader:
> def __init__(self, header_obj):
> self.headers = header_obj
> diff --git a/testenv/conf/server_conf.py b/testenv/conf/server_conf.py
> index d373931..c287bd7 100644
> --- a/testenv/conf/server_conf.py
> +++ b/testenv/conf/server_conf.py
> @@ -1,6 +1,7 @@
> -from conf import register
> +from conf import hook
>
>
> address@hidden()
> class ServerConf:
> def __init__(self, server_settings):
> self.server_settings = server_settings
> diff --git a/testenv/conf/server_files.py b/testenv/conf/server_files.py
> index 66829b3..bf6c163 100644
> --- a/testenv/conf/server_files.py
> +++ b/testenv/conf/server_files.py
> @@ -1,7 +1,7 @@
> -from conf import register
> +from conf import hook
>
>
> address@hidden()
> address@hidden()
> class ServerFiles:
> def __init__(self, server_files):
> self.server_files = server_files
> diff --git a/testenv/conf/urls.py b/testenv/conf/urls.py
> index 10bd930..6001586 100644
> --- a/testenv/conf/urls.py
> +++ b/testenv/conf/urls.py
> @@ -1,7 +1,7 @@
> -from conf import register
> +from conf import hook
>
>
> address@hidden(alias='Urls')
> address@hidden(alias='Urls')
> class URLs:
> def __init__(self, urls):
> self.urls = urls
> diff --git a/testenv/conf/wget_commands.py b/testenv/conf/wget_commands.py
> index 5db1808..a326bb5 100644
> --- a/testenv/conf/wget_commands.py
> +++ b/testenv/conf/wget_commands.py
> @@ -1,7 +1,7 @@
> -from conf import register
> +from conf import hook
>
>
> address@hidden()
> address@hidden()
> class WgetCommands:
> def __init__(self, commands):
> self.commands = commands
> --
> 1.8.3.2
>
>
--
Regards,
Chen Zihang,
Computer School of Wuhan University
---
此致
陈子杭
武汉大学计算机学院
- [Bug-wget] [GSoC PATCH 02/11] from WgetTest.py move WgetFile to misc, (continued)
- [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, 2014/03/14
- [Bug-wget] [GSoC PATCH 11/11] in conf, rename register to rule and hook, Zihang Chen, 2014/03/14
- Re: [Bug-wget] [GSoC PATCH 11/11] in conf, rename register to rule and hook,
Zihang Chen <=