facebook / facebook/TestSlide

Simplify sharing contexts at top level

未关闭
#13 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
enhancement help wanted TestSlide DSL
主要语言
Python
星标
149
派生
62
PR 合并指标
30 天内没有已合并 PR

描述

If we have a shared context defined in one file:

```
def some_shared_context(context):
@context.before
def before(self):
pass
```

and we want to use it at different files, we need to do this:

```
from wherever import some_shared_context

@context
def first(context):
context.shared_context(some_shared_context)
context.merge_context("some shared context")
```
and on the other file:
```
from wherever import some_shared_context

@context
def second(context):
context.shared_context(some_shared_context)
context.merge_context("some shared context")
```

We can somewhat easily modify the `merge_context` function to accept the function directly, simplifying things:

```
from wherever import some_shared_context

@context
def first(context):
context.merge_context(some_shared_context)
```
and on the other file
```
from wherever import some_shared_context

@context
def second(context):
context.merge_context(some_shared_context)
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。