facebook / facebook/TestSlide

Simplify sharing contexts at top level

Đang mở
#13 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement help wanted TestSlide DSL
Ngôn ngữ chính
Python
Star
149
Fork
62
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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)
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.