1 """Test that a plugin can be loaded by filename.
3 This file is copied to a location with the name "file.py",
4 and is then loaded from within the `test_cli.py` code.
13 class File(dotbot
.Plugin
):
14 def can_handle(self
, directive
: str) -> bool:
15 return directive
== "plugin_file"
17 def handle(self
, directive
: str, _data
: Any
) -> bool:
18 if directive
!= "plugin_file":
19 msg
= f
"File cannot handle directive {directive}"
21 self
._log
.debug("Attempting to get options from Context")
22 options
= self
._context
.options()
23 if len(options
.plugins
) != 1:
24 self
._log
.debug(f
"Context.options.plugins length is {len(options.plugins)}, expected 1")
26 if not options
.plugins
[0].endswith("file.py"):
27 self
._log
.debug(f
"Context.options.plugins[0] is {options.plugins[0]}, expected end with file.py")
30 with
open(os
.path
.abspath(os
.path
.expanduser("~/flag")), "w") as file:
31 file.write("file plugin loading works")