Skip to content

Commit

Permalink
Update README.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
atellaluca authored Nov 4, 2024
1 parent 10476cb commit d067681
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,13 @@ Here's a simple example showing how to use **ImportSpy** to validate that an imp
]
# Use ImportSpy to check if the importing module complies with the defined rules
module = Spy().importspy(spymodel=MyLibrarySpy)
# If the module passes validation, you can safely use it; otherwise, ImportSpy raises an error
if module:
print(f"Module '{module.__name__}' complies with the specified rules and is ready to use!")
else:
print("The importing module does not comply with the required structure.")
# Now you can access all the attributes of the module that imports your code
try:
module = Spy().importspy(spymodel=MyLibrarySpy)
# If the module passes validation, you can safely use it; otherwise, ImportSpy raises a ValueError
print(f"Module '{module.__name__}' complies with the specified rules and is ready to use!")
# Now you can access all the attributes of the module that imports your code
except ValueError as ve:
print("The importing module does not comply with the required structure:", ve)
Example of a Compliant Importing Python Module
==============================================
Expand Down Expand Up @@ -164,11 +162,7 @@ In the developer's code:
spy = Spy()
module = spy.importspy(spymodel=MyLibrarySpy)
if module:
print(f"Module {module.__name__} is using your library correctly!")
else:
print("The importing module is not complying with the rules.")
# If the module passes validation, you can safely use it; otherwise, ImportSpy raises a ValueError
In the external module that imports the developer's code:

Expand Down

0 comments on commit d067681

Please sign in to comment.