10000 test: rewrite test examples to use assignment expression · proofit404/stories@acae01c · GitHub
[go: up one dir, main page]

Skip to content

Commit acae01c

Browse files
dry-python-botproofit404
dry-python-bot
authored andcommitted
test: rewrite test examples to use assignment expression
Do not use Success() keyword arguments to assign variables in the context.
1 parent 9756571 commit acae01c

File tree

16 files changed

+228
-194
lines changed
  • 16 files changed

    +228
    -194
    lines changed

    tests/helpers/django_project/services.py

    Lines changed: 14 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -61,17 +61,20 @@ def buy(I):
    6161
    def find_category(self, ctx):
    6262

    6363
    category = load_category(ctx.category_id)
    64-
    return Success(category=category)
    64+
    ctx.category = category
    65+
    return Success()
    6566

    6667
    def find_price(self, ctx):
    6768

    6869
    price = load_price(ctx.price_id)
    69-
    return Success(price=price)
    70+
    ctx.price = price
    71+
    return Success()
    7072

    7173
    def find_profile(self, ctx):
    7274

    7375
    profile = load_profile(ctx.profile_id)
    74-
    return Success(profile=profile)
    76+
    ctx.profile = profile
    77+
    return Success()
    7578

    7679
    def check_balance(self, ctx):
    7780

    @@ -90,12 +93,14 @@ def persist_subscription(self, ctx):
    9093

    9194
    expires = calculate_period(ctx.price.period)
    9295
    subscription = create_subscription(ctx.profile, ctx.category, expires)
    93-
    return Success(subscription=subscription)
    96+
    ctx.subscription = subscription
    97+
    return Success()
    9498

    9599
    def send_subscription_notification(self, ctx):
    96100

    97101
    notification = send_notification("subscription", ctx.profile, ctx.category.name)
    98- F438
    return Success(notification=notification)
    102+
    ctx.notification = notification
    103+
    return Success()
    99104

    100105
    def show_category(self, ctx):
    101106

    @@ -118,7 +123,8 @@ def find_subscription(self, ctx):
    118123

    119124
    subscription = load_subscription(ctx.category_id, ctx.profile_id)
    120125
    if subscription:
    121-
    return Success(subscription=subscription)
    126+
    ctx.subscription = subscription
    127+
    return Success()
    122128
    else:
    123129
    return Failure(Errors.forbidden)
    124130

    @@ -133,7 +139,8 @@ def find_category(self, ctx):
    133139

    134140
    category = load_category(ctx.category_id)
    135141
    if category:
    136-
    return Success(category=category)
    142+
    ctx.category = category
    143+
    return Success()
    137144
    else:
    138145
    return Failure(Errors.not_found)
    139146

    tests/helpers/examples/context/coroutines.py

    Lines changed: 2 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -14,12 +14,8 @@ async def one(self, ctx):
    1414

    1515
    class NormalMethod(object):
    1616
    async def one(self, ctx):
    17-
    return Success(foo=self.foo)
    18-
    19-
    20-
    class AssignMethod(object):
    21-
    async def one(self, ctx):
    22-
    ctx.foo = 1
    17+
    ctx.foo = self.foo
    18+
    return Success()
    2319

    2420

    2521
    class DeleteMethod(object):

    tests/helpers/examples/context/functions.py

    Lines changed: 2 additions & 6 deletions
    Original file line numberDiff line numberDiff line change
    @@ -14,12 +14,8 @@ def one(self, ctx):
    1414

    1515
    class NormalMethod(object):
    1616
    def one(self, ctx):
    17-
    return Success(foo=self.foo)
    18-
    19-
    20-
    class AssignMethod(object):
    21-
    def one(self, ctx):
    22-
    ctx.foo = 1
    17+
    ctx.foo = self.foo
    18+
    return Success()
    2319

    2420

    2521
    class DeleteMethod(object):

    tests/helpers/examples/contract/cerberus/coroutines.py

    Lines changed: 19 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -13,17 +13,19 @@ async def one(self, ctx):
    1313

    1414
    class StringMethod(object):
    1515
    async def one(self, ctx):
    16-
    return Success(foo="1", bar=["2"])
    16+
    ctx.foo = "1"
    17+
    ctx.bar = ["2"]
    18+
    return Success()
    1719

    1820

    1921
    class WrongMethod(object):
    2022
    async def one(self, ctx):
    21-
    return Success(foo="<boom>", bar=["<boom>"])
    23+
    ctx.foo = "<boom>"
    2224

    2325

    2426
    class UnknownMethod(object):
    2527
    async def one(self, ctx):
    26-
    return Success(spam="0", quiz="1")
    28+
    ctx.spam = "0"
    2729

    2830

    2931
    class ExceptionMethod(object):
    @@ -34,7 +36,10 @@ async def one(self, ctx):
    3436
    class AliasMethod(object):
    3537
    async def one(self, ctx):
    3638
    value = {"key": "1"}
    37-
    return Success(foo=value, bar=value, baz=value)
    39+
    ctx.foo = value
    40+
    ctx.bar = value
    41+
    ctx.baz = value
    42+
    return Success()
    3843

    3944

    4045
    # Next child mixins.
    @@ -58,7 +63,9 @@ async def after(self, ctx):
    5863

    5964
    class StringParentMethod(object):
    6065
    async def before(self, ctx):
    61-
    return Success(foo="1", bar=["2"])
    66+
    ctx.foo = "1"
    67+
    ctx.bar = ["2"]
    68+
    return Success()
    6269

    6370
    async def after(self, ctx):
    6471
    return Success()
    @@ -85,15 +92,20 @@ async def finish(self, ctx):
    8592

    8693
    class StringRootMethod(object):
    8794
    async def start(self, ctx):
    88-
    return Success(foo="1", bar=["2"])
    95+
    ctx.foo = "1"
    96+
    ctx.bar = ["2"]
    97+
    return Success()
    8998

    9099
    async def finish(self, ctx):
    91100
    return Success()
    92101

    93102

    94103
    class StringWideRootMethod(object):
    95104
    async def start(self, ctx):
    96-
    return Success(foo="1", bar=["2"], baz="1")
    105+
    ctx.foo = "1"
    106+
    ctx.bar = ["2"]
    107+
    ctx.baz = "1"
    108+
    return Success()
    97109

    98110
    async def finish(self, ctx):
    99111
    return Success()

    tests/helpers/examples/contract/cerberus/functions.py

    Lines changed: 19 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -13,17 +13,19 @@ def one(self, ctx):
    1313

    1414
    class StringMethod(object):
    1515
    def one(self, ctx):
    16-
    return Success(foo="1", bar=["2"])
    16+
    ctx.foo = "1"
    17+
    ctx.bar = ["2"]
    18+
    return Success()
    1719

    1820

    1921
    class WrongMethod(object):
    2022
    def one(self, ctx):
    21-
    return Success(foo="<boom>", bar=["<boom>"])
    23+
    ctx.foo = "<boom>"
    2224

    2325

    2426
    class UnknownMethod(object):
    2527
    def one(self, ctx):
    26-
    return Success(spam="0", quiz="1")
    28+
    ctx.spam = "0"
    2729

    2830

    2931
    class ExceptionMethod(object):
    @@ -34,7 +36,10 @@ def one(self, ctx):
    3436
    class AliasMethod(object):
    3537
    def one(self, ctx):
    3638
    value = {"key": "1"}
    37-
    return Success(foo=value, bar=value, baz=value)
    39+
    ctx.foo = value
    40+
    ctx.bar = value
    41+
    ctx.baz = value
    42+
    return Success()
    3843

    3944

    4045
    # Next child mixins.
    @@ -58,7 +63,9 @@ def after(self, ctx):
    5863

    5964
    class StringParentMethod(object):
    6065
    def before(self, ctx):
    61-
    return Success(foo="1", bar=["2"])
    66+
    ctx.foo = "1"
    67+
    ctx.bar = ["2"]
    68+
    return Success()
    6269

    6370
    def after(self, ctx):
    6471
    return Success()
    @@ -85,15 +92,20 @@ def finish(self, ctx):
    8592

    8693
    class StringRootMethod(object):
    8794
    def start(self, ctx):
    88-
    return Success(foo="1", bar=["2"])
    95+
    ctx.foo = "1"
    96+
    ctx.bar = ["2"]
    97+
    return Success()
    8998

    9099
    def finish(self, ctx):
    91100
    return Success()
    92101

    93102

    94103
    class StringWideRootMethod(object):
    95104
    def start(self, ctx):
    96-
    return Success(foo="1", bar=["2"], baz="1")
    105+
    ctx.foo = "1"
    106+
    ctx.bar = ["2"]
    107+
    ctx.baz = "1"
    108+
    return Success()
    97109

    98110
    def finish(self, ctx):
    99111
    return Success()

    tests/helpers/examples/contract/marshmallow/coroutines.py

    Lines changed: 19 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -13,17 +13,19 @@ async def one(self, ctx):
    1313

    1414
    class StringMethod(object):
    1515
    async def one(self, ctx):
    16-
    return Success(foo="1", bar=["2"])
    16+
    ctx.foo = "1"
    17+
    ctx.bar = ["2"]
    18+
    return Success()
    1719

    1820

    1921
    class WrongMethod(object):
    2022
    async def one(self, ctx):
    21-
    return Success(foo="<boom>", bar=["<boom>"])
    23+
    ctx.foo = "<boom>"
    2224

    2325

    2426
    class UnknownMethod(object):
    2527
    async def one(self, ctx):
    26-
    return Success(spam="0", quiz="1")
    28+
    ctx.spam = "0"
    2729

    2830

    2931
    class ExceptionMethod(object):
    @@ -34,7 +36,10 @@ async def one(self, ctx):
    3436
    class AliasMethod(object):
    3537
    async def one(self, ctx):
    3638
    value = {"key": "1"}
    37-
    return Success(foo=value, bar=value, baz=value)
    39+
    ctx.foo = value
    40+
    ctx.bar = value
    41+
    ctx.baz = value
    42+
    return Success()
    3843

    3944

    4045
    # Next child mixins.
    @@ -58,7 +63,9 @@ async def after(self, ctx):
    5863

    5964
    class StringParentMethod(object):
    6065
    async def before(self, ctx):
    61-
    return Success(foo="1", bar=["2"])
    66+
    ctx.foo = "1"
    67+
    ctx.bar = ["2"]
    68+
    return Success()
    6269

    6370
    async def after(self, ctx):
    6471
    return Success()
    @@ -85,15 +92,20 @@ async def finish(self, ctx):
    8592

    8693
    class StringRootMethod(object):
    8794
    async def start(self, ctx):
    88-
    return Success(foo="1", bar=["2"])
    95+
    ctx.foo = "1"
    96+
    ctx.bar = ["2"]
    97+
    return Success()
    8998

    9099
    async def finish(self, ctx):
    91100
    return Success()
    92101

    93102

    94103
    class StringWideRootMethod(object):
    95104
    async def start(self, ctx):
    96-
    return Success(foo="1", bar=["2"], baz="1")
    105+
    ctx.foo = "1"
    106+
    ctx.bar = ["2"]
    107+
    ctx.baz = "1"
    108+
    return Success()
    97109

    98110
    async def finish(self, ctx):
    99111
    return Success()

    tests/helpers/examples/contract/marshmallow/functions.py

    Lines changed: 19 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -13,17 +13,19 @@ def one(self, ctx):
    1313

    1414
    class StringMethod(object):
    1515
    def one(self, ctx):
    16-
    return Success(foo="1", bar=["2"])
    16+
    ctx.foo = "1"
    17+
    ctx.bar = ["2"]
    18+
    return Success()
    1719

    1820

    1921
    class WrongMethod(object):
    2022
    def one(self, ctx):
    21-
    return Success(foo="<boom>", bar=["<boom>"])
    23+
    ctx.foo = "<boom>"
    2224

    2325

    2426
    class UnknownMethod(object):
    2527
    def one(self, ctx):
    26-
    return Success(spam="0", quiz="1")
    28+
    ctx.spam = "0"
    2729

    2830

    2931
    class ExceptionMethod(object):
    @@ -34,7 +36,10 @@ def one(self, ctx):
    3436
    class AliasMethod(object):
    3537
    def one(self, ctx):
    3638
    value = {"key": "1"}
    37-
    return Success(foo=value, bar=value, baz=value)
    39+
    ctx.foo = value
    40+
    ctx.bar = value
    41+
    ctx.baz = value
    42+
    return Success()
    3843

    3944

    4045
    # Next child mixins.
    @@ -58,7 +63,9 @@ def after(self, ctx):
    5863

    5964
    class StringParentMethod(object):
    6065
    def before(self, ctx):
    61-
    return Success(foo="1", bar=["2"])
    66+
    ctx.foo = "1"
    67+
    ctx.bar = ["2"]
    68+
    return Success()
    6269

    6370
    def after(self, ctx):
    6471
    return Success()
    @@ -85,15 +92,20 @@ def finish(self, ctx):
    8592

    8693
    class StringRootMethod(object):
    8794
    def start(self, ctx):
    88-
    return Success(foo="1", bar=["2"])
    95+
    ctx.foo = "1"
    96+
    ctx.bar = ["2"]
    97+
    return Success()
    8998

    9099
    def finish(self, ctx):
    91100
    return Success()
    92101

    93102

    94103
    class StringWideRootMethod(object):
    95104
    def start(self, ctx):
    96-
    return Success(foo="1", bar=["2"], baz="1")
    105+
    ctx.foo = "1"
    106+
    ctx.bar = ["2"]
    107+
    ctx.baz = "1"
    108+
    return Success()
    97109

    98110
    def finish(self, ctx):
    99111
    return Success()

    0 commit comments

    Comments
     (0)
    0