tessl install tessl/pypi-fastcore@1.8.0Python supercharged for fastai development
Agent Success
Agent success rate when using this tile
56%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.37x
Baseline
Agent success rate without this tile
41%
Build a comprehensive test suite for a simple data validation library. The validator will have basic functionality for checking data types, numeric ranges, and string formats. Your task is to write thorough tests using assertions to ensure the validator works correctly.
You are provided with a simple data validator that you need to test:
@describes
class DataValidator:
"""
A simple data validator for checking common data constraints.
"""
def validate_positive(self, value):
"""Returns True if value is positive, False otherwise."""
return value > 0
def validate_in_range(self, value, min_val, max_val):
"""Returns True if value is within [min_val, max_val], False otherwise."""
return min_val <= value <= max_val
def validate_email_format(self, email):
"""Returns True if email contains '@' and '.', raises ValueError if not a string."""
if not isinstance(email, str):
raise ValueError("Email must be a string")
return '@' in email and '.' in email
def calculate_average(self, numbers):
"""Returns the average of a list of numbers."""
if not numbers:
return 0.0
return sum(numbers) / len(numbers)
def process_data(self, data):
"""Processes data and returns uppercase version, raises TypeError if not string."""
if not isinstance(data, str):
raise TypeError("Data must be a string")
return data.upper()Write a comprehensive test suite in a test file that validates all the functionality of the DataValidator class. Your tests should verify:
@generates
DataValidator to test its methodsProvides testing and assertion utilities.