Skip to content

Commit

Permalink
1、重新整理reudom下的__init__模块
Browse files Browse the repository at this point in the history
2、增加timestamp模块
3、增加User_Agent模块
  • Loading branch information
BarryYBL committed Aug 17, 2020
1 parent 1ce2856 commit 6b0f167
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 19 deletions.
30 changes: 24 additions & 6 deletions reudom/__init__.py
Expand Up @@ -17,14 +17,32 @@
# specific language governing permissions and limitations
# under the License.

from .running.test_runner import main
from .case import TestCase
from .case import *
from .testdata import ddt, ddt_class
from .running.test_runner import main

# 跳过用例
from .skip import skip
import requests
from requests import *
from unittest import TestCase
from .skip import skip_if
from .skip import skip_unless

# request方法引入
from requests import post
from requests import get
from requests import put
from requests import head
from requests import patch
from requests import options

# 时间戳
from .testdata.timestamp import time

# ddt数据驱动
from .testdata.parameterizeds import ddt, ddt_class

# User-Agent 浏览器用户代理
from .testdata.User_Agent import Chrome, Safari, IE, Firefox
from .testdata.User_Agent import Chrome_phone, Safari_phone, IE_phone, Firefox_phone


__author__ = "Barry"

Expand Down
14 changes: 1 addition & 13 deletions reudom/case.py
Expand Up @@ -10,16 +10,4 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
"""Hook method for deconstructing the class fixture after running all tests in the class."""

def millisecond():
"""Get millisecond timestamp"""
times = time.time()
milliSecond = int(times * 1000)
return milliSecond

def seconds():
"""Get second time stamp"""
times = time.time()
Seconds = int(times * 10000)
return Seconds
"""Hook method for deconstructing the class fixture after running all tests in the class."""
20 changes: 20 additions & 0 deletions reudom/skip.py
Expand Up @@ -5,3 +5,23 @@ def skip(reason=None):
if reason is None:
reason = "Skip the use case."
return unittest.skip(reason)


def skip_if(condition, reason):
"""
Skip a test if the condition is true.
:param condition:
:param reason:
:return:
"""
return unittest.skipIf(condition, reason)


def skip_unless(condition, reason):
"""
Skip a test unless the condition is true.
:param condition:
:param reason:
:return:
"""
return unittest.skipUnless(condition, reason)
58 changes: 58 additions & 0 deletions reudom/testdata/User_Agent.py
@@ -0,0 +1,58 @@
"""
User-Agent 浏览器用户代理
* 支持 PC 端用户代理:Chrome、Safari、IE、Firefox
* 支持 移动端 用户代理:Chrome_phone、Safari_phone、IE_phone、Firefox_phone
"""


def Chrome():
"""PC--Chrome"""
chromePC = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) " \
"AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11"
return chromePC


def Safari():
"""PC--Safari"""
SafariPC = "User-Agent:Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) " \
"AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50"
return SafariPC


def IE():
"""PC--IE"""
IePC = "User-Agent:Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0;"
return IePC


def Firefox():
"""PC--Firefox"""
FirefoxPc = "User-Agent:Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"
return FirefoxPc


def Chrome_phone():
"""phone--Chrome"""
chromePhone = "User-Agent: Mozilla/5.0 (Linux; U; Android 2.2.1; zh-cn; HTC_Wildfire_A3333 Build/FRG83D) " \
"AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
return chromePhone


def Safari_phone():
"""phone--Safari"""
SafariPhone = "User-Agent:Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) " \
"AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5"
return SafariPhone


def IE_phone():
"""phone--IE"""
IePhone = "User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; " \
"IEMobile/9.0; HTC; Titan)"
return IePhone


def Firefox_phone():
"""phone--Firefox"""
FirefoxPhone = "User-Agent: Mozilla/5.0 (Androdi; Linux armv7l; rv:5.0) Gecko/ Firefox/5.0 fennec/5.0"
return FirefoxPhone
Empty file added reudom/testdata/__init__.py
Empty file.
File renamed without changes.
14 changes: 14 additions & 0 deletions reudom/testdata/timestamp.py
@@ -0,0 +1,14 @@
class time:
@staticmethod
def millisecond():
"""Get millisecond timestamp"""
times = time.time()
milliSecond = int(times * 1000)
return milliSecond

@staticmethod
def seconds():
"""Get second time stamp"""
times = time.time()
Seconds = int(times * 10000)
return Seconds

0 comments on commit 6b0f167

Please sign in to comment.