File size: 773 Bytes
1d120a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import sys
import json
from io import StringIO

def test_quality():
    """Tests if the expected functions and values are used"""
    with open("qa_questions.json") as f:
        qs = json.load(f)
    
    for q in qs:
        # Capture stdout
        stdout = StringIO()
        sys.stdout = stdout
        
        for include in q['includes']:
            assert include in stdout.getvalue(), f"Expected {include} in output"
        for exclude in q['excludes']:
            assert exclude not in stdout.getvalue(), f"Expected {exclude} not in output"
        for function in q['functions']:
            assert f"Invoking function call {function}" in stdout.getvalue(), f"{function} was not invoked"
        
        # Restore stdout
        sys.stdout = sys.__stdout__