python类text()的实例源码

test_record_properties.py 文件源码 项目:python-netsgiro 作者: otovo 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_transaction_specification_for_avtalegiro_payment_request(
        tn, ln, cn, text):
    original = netsgiro.records.TransactionSpecification(
        service_code=netsgiro.ServiceCode.AVTALEGIRO,
        transaction_type=(
            netsgiro.TransactionType.AVTALEGIRO_WITH_BANK_NOTIFICATION),
        transaction_number=tn,
        line_number=ln,
        column_number=cn,
        text=text,
    )

    ocr = original.to_ocr()
    record = netsgiro.records.TransactionSpecification.from_string(ocr)

    assert record.transaction_number == tn
    assert record.line_number == ln
    assert record.column_number == cn
    assert len(record.text) == 40
    assert record.text == original.text
test_app.py 文件源码 项目:chalice 作者: aws 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_can_return_text_even_with_binary_content_type_configured(
        create_event):
    demo = app.Chalice('demo-app')

    @demo.route('/index')
    def index_view():
        return app.Response(
            status_code=200,
            body='Plain text',
            headers={'Content-Type': 'text/plain'})

    event = create_event('/index', 'GET', {})
    event['headers']['Accept'] = 'application/octet-stream'
    response = demo(event, context=None)
    assert response['statusCode'] == 200
    assert response['body'] == 'Plain text'
    assert response['headers']['Content-Type'] == 'text/plain'
mock_yarn.py 文件源码 项目:yarnitor 作者: maxpoint 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def spark_application(app_id):
    """Mock of the Spark jobs REST resource."""
    if 'last' in request.args:
        return jsonify(redis.get(request.base_url))

    d = st.fixed_dictionaries({
        'jobId': st.integers(0),
        'name': st.text(),
        'submissionTime': st.text(),
        'completionTime': st.text(),
        'stageIds': st.lists(st.integers(0), average_size=3),
        'status': st.sampled_from(['SUCCEEDED', 'RUNNING', 'FAILED']),
        'numTasks': st.integers(0),
        'numActiveTasks': st.integers(0),
        'numCompletedTasks': st.integers(0),
        'numSkippedTasks': st.integers(0),
        'numFailedTasks': st.integers(0),
        'numActiveStages': st.integers(0),
        'numCompletedStages': st.integers(0),
        'numSkippedStages': st.integers(0),
        'numFailedStages': st.integers(0),
    })
    result = json.dumps(st.lists(d, average_size=3).example())
    redis.set(request.base_url, result)
    return jsonify(result)
service.py 文件源码 项目:TopChef 作者: TopChef 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def services(
        draw,
        ids=uuids(),
        names=text(),
        descriptions=text(),
        registration_schemas=dictionaries(text(), text()),
        result_schemas=dictionaries(text(), text()),
        are_available=booleans(),
        service_job_lists=job_lists(),
        timeouts=timedeltas()
) -> ServiceInterface:
    return Service(
        draw(ids), draw(names), draw(descriptions),
        draw(registration_schemas), draw(result_schemas),
        draw(are_available), draw(service_job_lists),
        draw(timeouts)
    )
strategies.py 文件源码 项目:txacme 作者: twisted 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def dns_labels():
    """
    Strategy for generating limited charset DNS labels.
    """
    # This is too limited, but whatever
    return (
        s.text(
            u'abcdefghijklmnopqrstuvwxyz0123456789-',
            min_size=1, max_size=25)
        .filter(
            lambda s: not any([
                s.startswith(u'-'),
                s.endswith(u'-'),
                s.isdigit(),
                s[2:4] == u'--',
            ])))
test_hypo.py 文件源码 项目:senf 作者: quodlibet 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_fsnative(text):
    assert isinstance(fsnative(text), fsnative)
test_hypo.py 文件源码 项目:senf 作者: quodlibet 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_text2fsn(text):
    assert isinstance(text2fsn(text), fsnative)
test_hypo.py 文件源码 项目:senf 作者: quodlibet 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_text_fsn_roudntrip(text):
    if u"\x00" in text:
        return
    assert isinstance(fsn2text(text2fsn(text)), text_type)
test_record_properties.py 文件源码 项目:python-netsgiro 作者: otovo 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def digits(min_size=10, max_size=None):
    max_size = max_size or min_size
    return st.text(string.digits, min_size=min_size, max_size=max_size)
test_record_properties.py 文件源码 项目:python-netsgiro 作者: otovo 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_transaction_amount_item_3_for_ocr_giro_transactions(tn, text):
    original = netsgiro.records.TransactionAmountItem3(
        service_code=netsgiro.ServiceCode.OCR_GIRO,
        transaction_type=(
            netsgiro.TransactionType.PURCHASE_WITH_TEXT),
        transaction_number=tn,
        text=text,
    )

    ocr = original.to_ocr()
    record = netsgiro.records.TransactionAmountItem3.from_string(ocr)

    assert record.transaction_number == tn
    assert record.text == original.text
test_explode.py 文件源码 项目:KiField 作者: xesscorp 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def random_prefix(draw):
    #limited to unicode letters, see
    #https://en.wikipedia.org/wiki/Unicode_character_property#General_Category
    categories = ['Ll', 'Lt', 'Lm', 'Lo']
    characters = st.lists(st.characters(whitelist_categories=categories), min_size = 1)
    prefix = st.text(alphabet = draw(characters), min_size = 1)
    return draw(prefix)
test_60_booleanvar.py 文件源码 项目:environconfig 作者: buguroo 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test_booleanvar_true(text):
    assert BooleanVar()._to_python(text) is True
test_60_booleanvar.py 文件源码 项目:environconfig 作者: buguroo 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_booleanvar_false(text):
    assert BooleanVar()._to_python(text) is False
test_60_booleanvar.py 文件源码 项目:environconfig 作者: buguroo 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_booleanvar_other(text):
    assume(text not in (TRUE_VALUES + FALSE_VALUES))
    with pytest.raises(ValueError):
        BooleanVar()._to_python(text)
test_60_stringvar.py 文件源码 项目:environconfig 作者: buguroo 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_stringvar_return_the_same_string(text):
    assert StringVar()._to_python(text) == text
__init__.py 文件源码 项目:cattrs 作者: Tinche 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def enums_of_primitives(draw):
    """Generate enum classes with primitive values."""
    if is_py2:
        names = draw(st.sets(st.text(alphabet=string.ascii_letters,
                                     min_size=1),
                             min_size=1))
    else:
        names = draw(st.sets(st.text(min_size=1), min_size=1))
    n = len(names)
    vals = draw(st.one_of(st.sets(st.one_of(
            st.integers(),
            st.floats(allow_nan=False),
            st.text(min_size=1)),
        min_size=n, max_size=n)))
    return Enum('HypEnum', list(zip(names, vals)))
__init__.py 文件源码 项目:cattrs 作者: Tinche 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def str_attrs(draw, defaults=None):
    """
    Generate a tuple of an attribute and a strategy that yields strs for that
    attribute.
    """
    default = NOTHING
    if defaults is True or (defaults is None and draw(st.booleans())):
        default = draw(st.text())
    return ((attr.ib(default=default), st.text()))
__init__.py 文件源码 项目:cattrs 作者: Tinche 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def dict_attrs(draw, defaults=None):
    """
    Generate a tuple of an attribute and a strategy that yields dictionaries
    for that attribute. The dictionaries map strings to integers.
    """
    default = NOTHING
    val_strat = st.dictionaries(keys=st.text(), values=st.integers())
    if defaults is True or (defaults is None and draw(st.booleans())):
        default_val = draw(val_strat)
        default = attr.Factory(lambda: default_val)
    return ((attr.ib(default=default), val_strat))
abbreviation_test.py 文件源码 项目:sofi 作者: tryexceptpass 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_text_and_title(title, text):
    assert(str(Abbreviation(title, text)) == "<abbr title=\"" + title + "\">" + text + "</abbr>")
abbreviation_test.py 文件源码 项目:sofi 作者: tryexceptpass 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_initialism():
    assert(str(Abbreviation("Title", "text", True)) == "<abbr title=\"Title\" class=\"initialism\">text</abbr>")
abbreviation_test.py 文件源码 项目:sofi 作者: tryexceptpass 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_custom_class_ident_style_and_attrs():
    assert(str(Abbreviation("Title", "text", True, cl='abclass', ident='123', style="font-size:0.9em;", attrs={"data-test": 'abc'}))
           == "<abbr title=\"Title\" id=\"123\" class=\"initialism abclass\" style=\"font-size:0.9em;\" data-test=\"abc\">text</abbr>")
test_hypothesis.py 文件源码 项目:presswork 作者: hangtwenty 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_hypothesis_text(s, each_text_maker):
    # have to get a fresh text maker EACH time function is invoked, due to Hypothesis quirk explained here:
    # http://hypothesis.works/articles/hypothesis-pytest-fixtures/
    text_maker = each_text_maker.clone()

    _input_tokenized = text_maker.input_text(s)

    sentences = text_maker.make_sentences(300)

    word_set_comparison = helpers.WordSetComparison(generated_tokens=sentences, input_tokenized=_input_tokenized)
    assert word_set_comparison.output_is_valid_strict()
_misc.py 文件源码 项目:stratis-cli 作者: stratis-storage 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def _device_list(minimum):
    """
    Get a device generating strategy.

    :param int minimum: the minimum number of devices, must be at least 0
    """
    return strategies.lists(
       strategies.text(
          alphabet=string.ascii_letters + "/",
          min_size=1
       ),
       min_size=minimum
    )
_misc.py 文件源码 项目:stratis-cli 作者: stratis-storage 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _device_list(minimum):
    """
    Get a device generating strategy.

    :param int minimum: the minimum number of devices, must be at least 0
    """
    return strategies.lists(
       strategies.text(
          alphabet=string.ascii_letters + "/",
          min_size=1
       ),
       min_size=minimum
    )
mock_yarn.py 文件源码 项目:yarnitor 作者: maxpoint 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def jsonify(text):
    """Substitute for flask.jsonify which accepts an already encoded
    JSON string and makes a response with 200 status and application/json
    Content-Type header.
    """
    return make_response(text, 200, {'Content-Type': 'application/json'})
test_request_utils.py 文件源码 项目:vws-python 作者: adamtheturtle 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_example(self) -> None:
        """
        Test a successful example of creating an Authorization header.
        """
        result = authorization_header(
            access_key=b'my_access_key',
            secret_key=b'my_secret_key',
            method=GET,
            content=b'{"something": "other"}',
            content_type='text/example',
            date='Sun, 22 Apr 2012 08:49:37 GMT.',
            request_path='/example_path',
        )

        assert result == b'VWS my_access_key:CetfV6Yl/3mSz/Xl0c+O1YjXKYg='
job.py 文件源码 项目:TopChef 作者: TopChef 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def jobs(
        draw,
        services=service_generator(),
        parameters=dictionaries(text(), text()),
) -> Job:
    return Job.new(
        draw(services),
        draw(parameters)
    )
service.py 文件源码 项目:TopChef 作者: TopChef 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def services(
        draw,
        names=text(),
        descriptions=text(),
        registration=dictionaries(text(), text()),
        results=dictionaries(text(), text())
) -> Service:
    return Service.new(
        name=draw(names),
        description=draw(descriptions),
        registration_schema=draw(registration),
        result_schema=draw(results)
    )
service_generator.py 文件源码 项目:TopChef 作者: TopChef 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def services(
        draw,
        service_id=uuids(), name=text(), description=text(),
        is_available=booleans()
) -> IService:
    return Service(
        draw(service_id), draw(name), draw(description), draw(is_available)
    )
test_services_list.py 文件源码 项目:TopChef 作者: TopChef 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def _valid_post_requests(
        draw,
        names: str=text(),
        descriptions: str=text(),
        job_registration_schemas: dict=dictionaries(text(), text()),
        job_result_schemas: dict=dictionaries(text(), text())
) -> dict:
    return {
        'name': draw(names),
        'description': draw(descriptions),
        'job_registration_schema': draw(job_registration_schemas),
        'job_result_schema': draw(job_result_schemas)
    }


问题


面经


文章

微信
公众号

扫码关注公众号