@@ -421,194 +421,194 @@ def test_iterdir() -> None:
421
421
}
422
422
423
423
424
- def test_exists_when_path_exists ():
424
+ def test_exists_when_path_exists () -> None :
425
425
ws = create_autospec (WorkspaceClient )
426
426
workspace_path = WorkspacePath (ws , "/test/path" )
427
427
ws .workspace .get_status .return_value = True
428
428
assert workspace_path .exists ()
429
429
430
430
431
- def test_exists_when_path_does_not_exist ():
431
+ def test_exists_when_path_does_not_exist () -> None :
432
432
ws = create_autospec (WorkspaceClient )
433
433
workspace_path = WorkspacePath (ws , "/test/path" )
434
434
ws .workspace .get_status .side_effect = NotFound ("Simulated NotFound" )
435
435
assert not workspace_path .exists ()
436
436
437
437
438
- def test_mkdir_creates_directory ():
438
+ def test_mkdir_creates_directory () -> None :
439
439
ws = create_autospec (WorkspaceClient )
440
440
workspace_path = WorkspacePath (ws , "/test/path" )
441
441
workspace_path .mkdir ()
442
442
ws .workspace .mkdirs .assert_called_once_with ("/test/path" )
443
443
444
444
445
- def test_rmdir_removes_directory ():
445
+ def test_rmdir_removes_directory () -> None :
446
446
ws = create_autospec (WorkspaceClient )
447
447
workspace_path = WorkspacePath (ws , "/test/path" )
448
448
workspace_path .rmdir ()
449
449
ws .workspace .delete .assert_called_once_with ("/test/path" , recursive = False )
450
450
451
451
452
- def test_is_dir_when_path_is_directory ():
452
+ def test_is_dir_when_path_is_directory () -> None :
453
453
ws = create_autospec (WorkspaceClient )
454
454
workspace_path = WorkspacePath (ws , "/test/path" )
455
455
ws .workspace .get_status .return_value = ObjectInfo (object_type = ObjectType .DIRECTORY )
456
456
assert workspace_path .is_dir ()
457
457
458
458
459
- def test_is_dir_when_path_is_not_directory ():
459
+ def test_is_dir_when_path_is_not_directory () -> None :
460
460
ws = create_autospec (WorkspaceClient )
461
461
workspace_path = WorkspacePath (ws , "/test/path" )
462
462
ws .workspace .get_status .return_value = ObjectInfo (object_type = ObjectType .FILE )
463
463
assert not workspace_path .is_dir ()
464
464
465
465
466
- def test_is_file_when_path_is_file ():
466
+ def test_is_file_when_path_is_file () -> None :
467
467
ws = create_autospec (WorkspaceClient )
468
468
workspace_path = WorkspacePath (ws , "/test/path" )
469
469
ws .workspace .get_status .return_value = ObjectInfo (object_type = ObjectType .FILE )
470
470
assert workspace_path .is_file ()
471
471
472
472
473
- def test_is_file_when_path_is_not_file ():
473
+ def test_is_file_when_path_is_not_file () -> None :
474
474
ws = create_autospec (WorkspaceClient )
475
475
workspace_path = WorkspacePath (ws , "/test/path" )
476
476
ws .workspace .get_status .return_value = ObjectInfo (object_type = ObjectType .DIRECTORY )
477
477
assert not workspace_path .is_file ()
478
478
479
479
480
- def test_is_notebook_when_path_is_notebook ():
480
+ def test_is_notebook_when_path_is_notebook () -> None :
481
481
ws = create_autospec (WorkspaceClient )
482
482
workspace_path = WorkspacePath (ws , "/test/path" )
483
483
ws .workspace .get_status .return_value = ObjectInfo (object_type = ObjectType .NOTEBOOK )
484
484
assert workspace_path .is_notebook ()
485
485
486
486
487
- def test_is_notebook_when_path_is_not_notebook ():
487
+ def test_is_notebook_when_path_is_not_notebook () -> None :
488
488
ws = create_autospec (WorkspaceClient )
489
489
workspace_path = WorkspacePath (ws , "/test/path" )
490
490
ws .workspace .get_status .return_value = ObjectInfo (object_type = ObjectType .FILE )
491
491
assert not workspace_path .is_notebook ()
492
492
493
493
494
- def test_open_file_in_read_binary_mode ():
494
+ def test_open_file_in_read_binary_mode () -> None :
495
495
ws = create_autospec (WorkspaceClient )
496
496
ws .workspace .download .return_value .__enter__ .return_value .read .return_value = b"test"
497
497
workspace_path = WorkspacePath (ws , "/test/path" )
498
498
assert workspace_path .read_bytes () == b"test"
499
499
500
500
501
- def test_open_file_in_write_binary_mode ():
501
+ def test_open_file_in_write_binary_mode () -> None :
502
502
ws = create_autospec (WorkspaceClient )
503
503
workspace_path = WorkspacePath (ws , "/test/path" )
504
504
workspace_path .write_bytes (b"test" )
505
505
ws .workspace .upload .assert_called_with ("/test/path" , b"test" , format = ImportFormat .AUTO )
506
506
507
507
508
- def test_open_file_in_read_text_mode ():
508
+ def test_open_file_in_read_text_mode () -> None :
509
509
ws = create_autospec (WorkspaceClient )
510
510
workspace_path = WorkspacePath (ws , "/test/path" )
511
511
ws .workspace .download .return_value .__enter__ .return_value .read .return_value = b"test"
512
512
assert workspace_path .read_text () == "test"
513
513
514
514
515
- def test_open_file_in_write_text_mode ():
515
+ def test_open_file_in_write_text_mode () -> None :
516
516
ws = create_autospec (WorkspaceClient )
517
517
workspace_path = WorkspacePath (ws , "/test/path" )
518
518
workspace_path .write_text ("test" )
519
519
ws .workspace .upload .assert_called_with ("/test/path" , "test" , format = ImportFormat .AUTO )
520
520
521
521
522
- def test_open_file_in_invalid_mode ():
522
+ def test_open_file_in_invalid_mode () -> None :
523
523
ws = create_autospec (WorkspaceClient )
524
524
workspace_path = WorkspacePath (ws , "/test/path" )
525
525
with pytest .raises (ValueError ):
526
526
workspace_path .open (mode = "invalid" )
527
527
528
528
529
- def test_suffix_when_file_has_extension ():
529
+ def test_suffix_when_file_has_extension () -> None :
530
530
ws = create_autospec (WorkspaceClient )
531
531
workspace_path = WorkspacePath (ws , "/test/path.py" )
532
532
assert workspace_path .suffix == ".py"
533
533
534
534
535
- def test_suffix_when_file_is_notebook_and_language_matches ():
535
+ def test_suffix_when_file_is_notebook_and_language_matches () -> None :
536
536
ws = create_autospec (WorkspaceClient )
537
537
ws .workspace .get_status .return_value = ObjectInfo (language = Language .PYTHON , object_type = ObjectType .NOTEBOOK )
538
538
539
539
workspace_path = WorkspacePath (ws , "/test/path" )
540
540
assert workspace_path .suffix == ".py"
541
541
542
542
543
- def test_suffix_when_file_is_notebook_and_language_does_not_match ():
543
+ def test_suffix_when_file_is_notebook_and_language_does_not_match () -> None :
544
544
ws = create_autospec (WorkspaceClient )
545
545
ws .workspace .get_status .return_value = ObjectInfo (language = None , object_type = ObjectType .NOTEBOOK )
546
546
547
547
workspace_path = WorkspacePath (ws , "/test/path" )
548
548
assert workspace_path .suffix == ""
549
549
550
550
551
- def test_suffix_when_file_is_not_notebook ():
551
+ def test_suffix_when_file_is_not_notebook () -> None :
552
552
ws = create_autospec (WorkspaceClient )
553
553
ws .workspace .get_status .return_value = ObjectInfo (language = Language .PYTHON , object_type = ObjectType .FILE )
554
554
555
555
workspace_path = WorkspacePath (ws , "/test/path" )
556
556
assert workspace_path .suffix == ""
557
557
558
558
559
- def test_mkdir_creates_directory_with_valid_mode ():
559
+ def test_mkdir_creates_directory_with_valid_mode () -> None :
560
560
ws = create_autospec (WorkspaceClient )
561
561
workspace_path = WorkspacePath (ws , "/test/path" )
562
562
workspace_path .mkdir (mode = 0o600 )
563
563
ws .workspace .mkdirs .assert_called_once_with ("/test/path" )
564
564
565
565
566
- def test_mkdir_raises_error_with_invalid_mode ():
566
+ def test_mkdir_raises_error_with_invalid_mode () -> None :
567
567
ws = create_autospec (WorkspaceClient )
568
568
workspace_path = WorkspacePath (ws , "/test/path" )
569
569
with pytest .raises (ValueError ):
570
570
workspace_path .mkdir (mode = 0o700 )
571
571
572
572
573
- def test_rmdir_removes_directory_non_recursive ():
573
+ def test_rmdir_removes_directory_non_recursive () -> None :
574
574
ws = create_autospec (WorkspaceClient )
575
575
workspace_path = WorkspacePath (ws , "/test/path" )
576
576
workspace_path .rmdir ()
577
577
ws .workspace .delete .assert_called_once_with ("/test/path" , recursive = False )
578
578
579
579
580
- def test_rmdir_removes_directory_recursive ():
580
+ def test_rmdir_removes_directory_recursive () -> None :
581
581
ws = create_autospec (WorkspaceClient )
582
582
workspace_path = WorkspacePath (ws , "/test/path" )
583
583
workspace_path .rmdir (recursive = True )
584
584
ws .workspace .delete .assert_called_once_with ("/test/path" , recursive = True )
585
585
586
586
587
- def test_rename_file_without_overwrite ():
587
+ def test_rename_file_without_overwrite () -> None :
588
588
ws = create_autospec (WorkspaceClient )
589
589
workspace_path = WorkspacePath (ws , "/test/path" )
590
590
ws .workspace .download .return_value .__enter__ .return_value .read .return_value = b"test"
591
591
workspace_path .rename ("/new/path" )
592
592
ws .workspace .upload .assert_called_once_with ("/new/path" , b"test" , format = ImportFormat .AUTO , overwrite = False )
593
593
594
594
595
- def test_rename_file_with_overwrite ():
595
+ def test_rename_file_with_overwrite () -> None :
596
596
ws = create_autospec (WorkspaceClient )
597
597
workspace_path = WorkspacePath (ws , "/test/path" )
598
598
ws .workspace .download .return_value .__enter__ .return_value .read .return_value = b"test"
599
599
workspace_path .rename ("/new/path" , overwrite = True )
600
600
ws .workspace .upload .assert_called_once_with ("/new/path" , b"test" , format = ImportFormat .AUTO , overwrite = True )
601
601
602
602
603
- def test_unlink_existing_file ():
603
+ def test_unlink_existing_file () -> None :
604
604
ws = create_autospec (WorkspaceClient )
605
605
workspace_path = WorkspacePath (ws , "/test/path" )
606
606
ws .workspace .get_status .return_value = True
607
607
workspace_path .unlink ()
608
608
ws .workspace .delete .assert_called_once_with ("/test/path" )
609
609
610
610
611
- def test_unlink_non_existing_file ():
611
+ def test_unlink_non_existing_file () -> None :
612
612
ws = create_autospec (WorkspaceClient )
613
613
workspace_path = WorkspacePath (ws , "/test/path" )
614
614
ws .workspace .get_status .side_effect = NotFound ("Simulated NotFound" )
@@ -640,23 +640,23 @@ def test_relative_to() -> None:
640
640
_ = WorkspacePath (ws , "/home/bob" ).relative_to ("/home/../usr" , walk_up = True )
641
641
642
642
643
- def test_as_fuse_in_databricks_runtime ():
643
+ def test_as_fuse_in_databricks_runtime () -> None :
644
644
with patch .dict ("os.environ" , {"DATABRICKS_RUNTIME_VERSION" : "14.3" }):
645
645
ws = create_autospec (WorkspaceClient )
646
646
workspace_path = WorkspacePath (ws , "/test/path" )
647
647
result = workspace_path .as_fuse ()
648
648
assert str (result ) == "/Workspace/test/path"
649
649
650
650
651
- def test_as_fuse_outside_databricks_runtime ():
651
+ def test_as_fuse_outside_databricks_runtime () -> None :
652
652
with patch .dict ("os.environ" , {}, clear = True ):
653
653
ws = create_autospec (WorkspaceClient )
654
654
workspace_path = WorkspacePath (ws , "/test/path" )
655
655
result = workspace_path .as_fuse ()
656
656
assert str (result ) == "/Workspace/test/path"
657
657
658
658
659
- def test_home_directory ():
659
+ def test_home_directory () -> None :
660
660
ws = create_autospec (WorkspaceClient )
661
661
ws .current_user .me .return_value .user_name = "test_user"
662
662
workspace_path = WorkspacePath (ws , "/test/path" )
@@ -675,63 +675,63 @@ def test_absolute() -> None:
675
675
_ = WorkspacePath (ws , "relative/path" ).absolute ()
676
676
677
677
678
- def test_is_dir_when_object_type_is_directory ():
678
+ def test_is_dir_when_object_type_is_directory () -> None :
679
679
ws = create_autospec (WorkspaceClient )
680
680
workspace_path = WorkspacePath (ws , "/test/path" )
681
681
workspace_path ._object_info .object_type = ObjectType .DIRECTORY
682
682
assert workspace_path .is_dir () is True
683
683
684
684
685
- def test_is_dir_when_object_type_is_not_directory ():
685
+ def test_is_dir_when_object_type_is_not_directory () -> None :
686
686
ws = create_autospec (WorkspaceClient )
687
687
workspace_path = WorkspacePath (ws , "/test/path" )
688
688
workspace_path ._object_info .object_type = ObjectType .FILE
689
689
assert workspace_path .is_dir () is False
690
690
691
691
692
- def test_is_dir_when_databricks_error_occurs ():
692
+ def test_is_dir_when_databricks_error_occurs () -> None :
693
693
ws = create_autospec (WorkspaceClient )
694
694
workspace_path = WorkspacePath (ws , "/test/path" )
695
695
ws .workspace .get_status .side_effect = NotFound ("Simulated NotFound" )
696
696
assert workspace_path .is_dir () is False
697
697
698
698
699
- def test_is_file_when_object_type_is_file ():
699
+ def test_is_file_when_object_type_is_file () -> None :
700
700
ws = create_autospec (WorkspaceClient )
701
701
workspace_path = WorkspacePath (ws , "/test/path" )
702
702
workspace_path ._object_info .object_type = ObjectType .FILE
703
703
assert workspace_path .is_file () is True
704
704
705
705
706
- def test_is_file_when_object_type_is_not_file ():
706
+ def test_is_file_when_object_type_is_not_file () -> None :
707
707
ws = create_autospec (WorkspaceClient )
708
708
workspace_path = WorkspacePath (ws , "/test/path" )
709
709
workspace_path ._object_info .object_type = ObjectType .DIRECTORY
710
710
assert workspace_path .is_file () is False
711
711
712
712
713
- def test_is_file_when_databricks_error_occurs ():
713
+ def test_is_file_when_databricks_error_occurs () -> None :
714
714
ws = create_autospec (WorkspaceClient )
715
715
workspace_path = WorkspacePath (ws , "/test/path" )
716
716
ws .workspace .get_status .side_effect = NotFound ("Simulated NotFound" )
717
717
assert workspace_path .is_file () is False
718
718
719
719
720
- def test_is_notebook_when_object_type_is_notebook ():
720
+ def test_is_notebook_when_object_type_is_notebook () -> None :
721
721
ws = create_autospec (WorkspaceClient )
722
722
workspace_path = WorkspacePath (ws , "/test/path" )
723
723
workspace_path ._object_info .object_type = ObjectType .NOTEBOOK
724
724
assert workspace_path .is_notebook () is True
725
725
726
726
727
- def test_is_notebook_when_object_type_is_not_notebook ():
727
+ def test_is_notebook_when_object_type_is_not_notebook () -> None :
728
728
ws = create_autospec (WorkspaceClient )
729
729
workspace_path = WorkspacePath (ws , "/test/path" )
730
730
workspace_path ._object_info .object_type = ObjectType .FILE
731
731
assert workspace_path .is_notebook () is False
732
732
733
733
734
- def test_is_notebook_when_databricks_error_occurs ():
734
+ def test_is_notebook_when_databricks_error_occurs () -> None :
735
735
ws = create_autospec (WorkspaceClient )
736
736
workspace_path = WorkspacePath (ws , "/test/path" )
737
737
ws .workspace .get_status .side_effect = NotFound ("Simulated NotFound" )
@@ -946,7 +946,7 @@ def test_glob_case_insensitive() -> None:
946
946
assert set (WorkspacePath (ws , "/etc" ).glob ("PasSWd" , case_sensitive = False )) == {WorkspacePath (ws , "/etc/passwd" )}
947
947
948
948
949
- def test_globbing_when_nested_json_files_exist ():
949
+ def test_globbing_when_nested_json_files_exist () -> None :
950
950
ws = create_autospec (WorkspaceClient )
951
951
workspace_path = WorkspacePath (ws , "/test/path" )
952
952
ws .workspace .get_status .return_value = ObjectInfo (object_type = ObjectType .DIRECTORY )
0 commit comments