Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Implement a pytest plugin to help with testing

Aperta
#135 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
testing

Direzione di ricerca

Inizia leggendo la discussione su pytest-plugin in PR #5108 e gli esempi di fixture e context-manager richiesti in questa issue. Il lavoro è completo quando una fixture pytest riutilizzabile o un context-manager sovrascrive is_feature_enabled, get_flag e get_feature_value per i valori di Flag forniti nell'ambito del test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

As part of some work in the core Flagsmith repository, we found that there isn't currently a good, generic solution for mocking the flagsmith client to return a given value for a flag at a given time. The ideal implementation as I see it would be to build a fixture that can be used as a context manager, or a function that looks something like this:

def my_test_function(set_flags: FlagsmithSetFlagsFixture) -> None:
    with override_flagsmith(flags=[Flag(name="foo", enabled=True, value="foobar")]):
        # in here, any calls to Flags.is_feature_enabled,Flags.get_flag and Flags.get_feature_value 
        # for the feature "foo" will return the values provided as an argument to override_flagsmith
        ...

def my_other_test_function(set_flags: FlagsmithSetFlagsFixture) -> None:
    set_flags(flags=[Flag(name="foo", enabled=True, value="foobar")])
    
    # For the remainder of this test, any calls to Flags.is_feature_enabled,Flags.get_flag 
    # and Flags.get_feature_value for the feature "foo" will return the values provided as 
    # an argument to override_flagsmith

See PR here for more context / discussions

Lingua principale
Python
Stelle
24
Fork
12
Merge medio
15h 43m
PR unite (30g)
4

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Flagsmith/flagsmith-python-client

Tutte le issue di Flagsmith/flagsmith-python-client

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.