@@ -584,56 +584,60 @@ def test_Particle_equivalent_cases(equivalent_particles):
584584 run_test_equivalent_calls (Particle , * equivalent_particles )
585585
586586
587- # arg , kwargs, attribute, exception
587+ # args , kwargs, attribute, exception
588588test_Particle_error_table = [
589- ("a" , {}, "" , InvalidParticleError ),
590- ("d+" , {"mass_numb" : 9 }, "" , InvalidParticleError ),
591- ("H" , {"mass_numb" : 99 }, "" , InvalidParticleError ),
592- ("Au-818" , {}, "" , InvalidParticleError ),
593- ("Au-12" , {}, "" , InvalidParticleError ),
594- ("Au" , {"mass_numb" : 13 }, "" , InvalidParticleError ),
595- ("Au" , {"mass_numb" : 921 }, "" , InvalidParticleError ),
596- ("e-" , {"Z" : - 1 }, "" , InvalidParticleError ),
597- ("e-" , {}, ".atomic_number" , InvalidElementError ),
598- ("alpha" , {}, ".standard_atomic_weight" , InvalidElementError ),
599- ("Fe-56" , {}, ".standard_atomic_weight" , InvalidElementError ),
600- ("e-" , {}, ".standard_atomic_weight" , InvalidElementError ),
601- ("tau-" , {}, ".element_name" , InvalidElementError ),
602- ("tau+" , {}, ".atomic_number" , InvalidElementError ),
603- ("neutron" , {}, ".atomic_number" , InvalidElementError ),
604- ("H" , {"Z" : 0 }, ".mass_number" , InvalidIsotopeError ),
605- ("neutron" , {}, ".mass_number" , InvalidIsotopeError ),
606- ("He" , {"mass_numb" : 4 }, ".charge" , ChargeError ),
607- ("He" , {"mass_numb" : 4 }, ".charge_number" , ChargeError ),
608- ("Fe" , {}, ".spin" , MissingParticleDataError ),
609- ("nu_e" , {}, ".mass" , MissingParticleDataError ),
610- ("Og" , {}, ".standard_atomic_weight" , MissingParticleDataError ),
611- (Particle ("C-14" ), {"mass_numb" : 13 }, "" , InvalidParticleError ),
612- (Particle ("Au 1+" ), {"Z" : 2 }, "" , InvalidParticleError ),
613- ([], {}, "" , TypeError ),
614- ("Fe" , {}, ".ionize()" , ChargeError ),
615- ("D" , {}, ".recombine()" , ChargeError ),
616- ("Fe 26+" , {}, ".ionize()" , InvalidIonError ),
617- ("Fe 6+" , {}, ".ionize(-1)" , ValueError ),
618- ("Fe 25+" , {}, ".recombine(0)" , ValueError ),
619- ("Fe 6+" , {}, ".ionize(4.6)" , TypeError ),
620- ("Fe 25+" , {}, ".recombine(8.2)" , TypeError ),
621- ("e-" , {}, ".ionize()" , InvalidElementError ),
622- ("e+" , {}, ".recombine()" , InvalidElementError ),
589+ (["a" ], {}, "" , InvalidParticleError ),
590+ (["d+" ], {"mass_numb" : 9 }, "" , InvalidParticleError ),
591+ (["H" ], {"mass_numb" : 99 }, "" , InvalidParticleError ),
592+ (["Au-818" ], {}, "" , InvalidParticleError ),
593+ (["Au-12" ], {}, "" , InvalidParticleError ),
594+ (["Au" ], {"mass_numb" : 13 }, "" , InvalidParticleError ),
595+ (["Au" ], {"mass_numb" : 921 }, "" , InvalidParticleError ),
596+ (["e-" ], {"Z" : - 1 }, "" , InvalidParticleError ),
597+ (["e-" ], {}, ".atomic_number" , InvalidElementError ),
598+ (["alpha" ], {}, ".standard_atomic_weight" , InvalidElementError ),
599+ (["Fe-56" ], {}, ".standard_atomic_weight" , InvalidElementError ),
600+ (["e-" ], {}, ".standard_atomic_weight" , InvalidElementError ),
601+ (["tau-" ], {}, ".element_name" , InvalidElementError ),
602+ (["tau+" ], {}, ".atomic_number" , InvalidElementError ),
603+ (["neutron" ], {}, ".atomic_number" , InvalidElementError ),
604+ (["H" ], {"Z" : 0 }, ".mass_number" , InvalidIsotopeError ),
605+ (["neutron" ], {}, ".mass_number" , InvalidIsotopeError ),
606+ (["He" ], {"mass_numb" : 4 }, ".charge" , ChargeError ),
607+ (["He" ], {"mass_numb" : 4 }, ".charge_number" , ChargeError ),
608+ (["Fe" ], {}, ".spin" , MissingParticleDataError ),
609+ (["nu_e" ], {}, ".mass" , MissingParticleDataError ),
610+ (["Og" ], {}, ".standard_atomic_weight" , MissingParticleDataError ),
611+ ([Particle ("C-14" )], {"mass_numb" : 13 }, "" , InvalidParticleError ),
612+ ([Particle ("Au 1+" )], {"Z" : 2 }, "" , InvalidParticleError ),
613+ ([[]], {}, "" , TypeError ),
614+ (["Fe" ], {}, ".ionize()" , ChargeError ),
615+ (["D" ], {}, ".recombine()" , ChargeError ),
616+ (["Fe 26+" ], {}, ".ionize()" , InvalidIonError ),
617+ (["Fe 6+" ], {}, ".ionize(-1)" , ValueError ),
618+ (["Fe 25+" ], {}, ".recombine(0)" , ValueError ),
619+ (["Fe 6+" ], {}, ".ionize(4.6)" , TypeError ),
620+ (["Fe 25+" ], {}, ".recombine(8.2)" , TypeError ),
621+ (["e-" ], {}, ".ionize()" , InvalidElementError ),
622+ (["e+" ], {}, ".recombine()" , InvalidElementError ),
623+ (["H" , 1 ], {}, "" , TypeError ),
624+ (["H" , 1 , 1 ], {}, "" , TypeError ),
623625]
624626
625627
626- @pytest .mark .parametrize ("arg, kwargs, attribute, exception" , test_Particle_error_table )
627- def test_Particle_errors (arg , kwargs , attribute , exception ):
628+ @pytest .mark .parametrize (
629+ "args, kwargs, attribute, exception" , test_Particle_error_table
630+ )
631+ def test_Particle_errors (args , kwargs , attribute , exception ):
628632 """
629633 Test that the appropriate exceptions are raised during the creation
630634 and use of a `~plasmapy.particles.Particle` object.
631635 """
632636 with pytest .raises (exception ):
633- exec (f"Particle(arg , **kwargs){ attribute } " )
637+ exec (f"Particle(*args , **kwargs){ attribute } " )
634638 pytest .fail (
635639 f"The following command: "
636- f"\n \n { call_string (Particle , arg , kwargs )} { attribute } \n \n "
640+ f"\n \n { call_string (Particle , args , kwargs )} { attribute } \n \n "
637641 f"did not raise a { exception .__name__ } as expected"
638642 )
639643
0 commit comments